Skip to content

Commit

Permalink
Start Tests component
Browse files Browse the repository at this point in the history
  • Loading branch information
jedrzejchalubek committed Mar 13, 2017
1 parent fa63be4 commit 3142494
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/Gin/Foundation/Testing/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Gin\Foundation\Testing;

use Brain\Monkey;
use Mockery;
use PHPUnit_Framework_TestCase;
use Exception;

abstract class TestCase extends PHPUnit_Framework_TestCase
{
/**
* Path of file to autoload.
*
* @var string
*/
protected $file;

/**
* Setup before each test.
*
* @return void
*/
protected function setUp()
{
if (! isset($this->file)) {
throw new Exception('You have to define file to be autoloaded for tests.');
}

parent::setUp();
Monkey::setUpWP();

$this->requireSrcFile($this->file);
}

/**
* Setup after each test.
*
* @return void
*/
protected function tearDown()
{
Monkey::tearDownWP();
Mockery::close();
parent::tearDown();
}

/**
* Require theme source file.
*
* @param string $file
* @return mixed
*/
protected function requireSrcFile($file)
{
require_once dirname(__DIR__) . '/src/' . $file;
}
}

0 comments on commit 3142494

Please sign in to comment.