added tearDown method for header tests
Signed-off-by: osaid <osaid.nasir@gmail.com>
This commit is contained in:
parent
02125d2fc9
commit
887b661690
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user