diff --git a/test/PMATestCase.php b/test/PMATestCase.php index c20e04fb67..e4a690725b 100644 --- a/test/PMATestCase.php +++ b/test/PMATestCase.php @@ -6,13 +6,10 @@ * @package PhpMyAdmin-test */ -/** - * Base class for phpMyAdmin tests. - * - * @package PhpMyAdmin-test - */ class PMATestCase extends PHPUnit_Framework_TestCase { + public $restoreInstance; + public $attrInstance; /** * This method is called before the first test of this test class is run. */ @@ -22,7 +19,7 @@ class PMATestCase extends PHPUnit_Framework_TestCase $GLOBALS['cfg'] = $cfg; } /** - * Creates mock of Response object + * Creates mock of Response object for header testing * * @param string $param parameter for header method * @@ -30,7 +27,7 @@ class PMATestCase extends PHPUnit_Framework_TestCase */ public function mockResponse($param) { - $restoreInstance = PMA\libraries\Response::getInstance(); + $this->restoreInstance = PMA\libraries\Response::getInstance(); $mockResponse = $this->getMockBuilder('PMA\libraries\Response') ->disableOriginalConstructor() @@ -46,9 +43,8 @@ class PMATestCase extends PHPUnit_Framework_TestCase ->with() ->will($this->returnValue(false)); - $attrInstance = new ReflectionProperty('PMA\libraries\Response', '_instance'); - $attrInstance->setAccessible(true); - $attrInstance->setValue($mockResponse); - $attrInstance->setValue($restoreInstance); + $this->attrInstance = new ReflectionProperty('PMA\libraries\Response', '_instance'); + $this->attrInstance->setAccessible(true); + $this->attrInstance->setValue($mockResponse); } } \ No newline at end of file diff --git a/test/libraries/core/PMA_headerLocation_test.php b/test/libraries/core/PMA_headerLocation_test.php index 0bbc0b822e..f311196778 100644 --- a/test/libraries/core/PMA_headerLocation_test.php +++ b/test/libraries/core/PMA_headerLocation_test.php @@ -68,6 +68,8 @@ class PMA_HeaderLocation_Test extends PMATestCase $this->mockResponse('Location: ' . $testUri); PMA_sendHeaderLocation($testUri); // sets $GLOBALS['header'] + $this->tearDown(); + $this->mockResponse('Refresh: 0; ' . $testUri); PMA_sendHeaderLocation($testUri, true); // sets $GLOBALS['header'] } @@ -147,4 +149,18 @@ class PMA_HeaderLocation_Test extends PMATestCase $attrInstance->setValue($restoreInstance); } + /** + *Tear down function for mockResponse method + * + *@return void + */ + public function tearDown() + { + if(isset($this->attrInstance, $this->restoreInstance)) + { + $this->attrInstance->setValue($this->restoreInstance); + unset($this->restoreInstance); + unset($this->attrInstance); + } + } } \ No newline at end of file