-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa63be4
commit 3142494
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |