Skip to content

Commit

Permalink
Remove WP_Mock TestCase method referencing method removed from PhpUnit (
Browse files Browse the repository at this point in the history
#193)

Co-authored-by: Fulvio Notarstefano <[email protected]>
  • Loading branch information
nmolham-godaddy and unfulvio-godaddy committed Jan 3, 2023
1 parent 5733848 commit 212424d
Showing 1 changed file with 31 additions and 40 deletions.
71 changes: 31 additions & 40 deletions php/WP_Mock/Tools/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,42 @@
use ReflectionException;
use ReflectionMethod;
use RuntimeException;
use Text_Template;
use WP_Mock;
use WP_Mock\Tools\Constraints\ExpectationsMet;
use WP_Mock\Tools\Constraints\IsEqualHtml;

/**
* WP_Mock test case.
*
* Projects using WP_Mock can extend this class in their unit tests.
*/
abstract class TestCase extends \PHPUnit\Framework\TestCase
{
protected $mockedStaticMethods = array();
/** @var array<string, Mockery\Mock> */
protected $mockedStaticMethods = [];

/**
* @var array
*/
protected $__default_post = array();
/** @var array<mixed> */
protected $__default_post = [];

/**
* @var array
*/
protected $__default_get = array();
/** @var array<mixed> */
protected $__default_get = [];

/**
* @var array
*/
protected $__default_request = array();
/** @var array<mixed> */
protected $__default_request = [];

/**
* @var bool|callable
*/
/** @var bool|callable */
protected $__contentFilterCallback = false;

/** @var array<string> */
protected $testFiles = [];

/**
* @var array
* Sets up the test case.
*
* This method is called before each test.
*
* @return void
*/
protected $testFiles = array();

public function setUp(): void
{
$this->requireFileDependencies();
Expand All @@ -59,17 +61,22 @@ public function setUp(): void
$this->cleanGlobals();
}

/**
* Tears down the test case.
*
* This method is called after each test.
*/
public function tearDown(): void
{
WP_Mock::tearDown();

$this->cleanGlobals();

$this->mockedStaticMethods = array();
$this->mockedStaticMethods = [];

$_GET = array();
$_POST = array();
$_REQUEST = array();
$_GET = [];
$_POST = [];
$_REQUEST = [];
}

public function assertActionsCalled()
Expand Down Expand Up @@ -146,22 +153,6 @@ public function assertEqualsHTML($expected, $actual, $message = '')
$this->assertThat($actual, $constraint, $message);
}

/**
* Nuke the globals from orbit for process isolation
*
* See http://kpayne.me/2012/07/02/phpunit-process-isolation-and-constant-already-defined/
* for more details
*
* {@inheritdoc}
*/
protected function prepareTemplate(Text_Template $template)
{
$template->setVar(array(
'globals' => '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = \'' . $GLOBALS['__PHPUNIT_BOOTSTRAP'] . '\';',
));
parent::prepareTemplate($template);
}


/**
* Mocks a static method of a class.
Expand Down

0 comments on commit 212424d

Please sign in to comment.