Use shared mock for response without any header
Fixes #12079 Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
ffb28560c7
commit
ce9f84e477
@ -43,15 +43,17 @@ class PMATestCase extends PHPUnit_Framework_TestCase
|
||||
|
||||
$param = func_get_args();
|
||||
|
||||
if (is_array($param[0])) {
|
||||
$header_method = $mockResponse->expects($this->exactly(count($param)))
|
||||
->method('header');
|
||||
if (count($param) > 0) {
|
||||
if (is_array($param[0])) {
|
||||
$header_method = $mockResponse->expects($this->exactly(count($param)))
|
||||
->method('header');
|
||||
|
||||
call_user_func_array(array($header_method, 'withConsecutive'), $param);
|
||||
} else {
|
||||
$mockResponse->expects($this->once())
|
||||
->method('header')
|
||||
->with($param[0]);
|
||||
call_user_func_array(array($header_method, 'withConsecutive'), $param);
|
||||
} else {
|
||||
$mockResponse->expects($this->once())
|
||||
->method('header')
|
||||
->with($param[0]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->attrInstance = new ReflectionProperty('PMA\libraries\Response', '_instance');
|
||||
|
||||
@ -126,27 +126,8 @@ class PMA_HeaderLocation_Test extends PMATestCase
|
||||
|
||||
$this->expectOutputString($header);
|
||||
|
||||
$restoreInstance = PMA\libraries\Response::getInstance();
|
||||
|
||||
$mockResponse = $this->getMockBuilder('PMA\libraries\Response')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('disable', 'header', 'headersSent'))
|
||||
->getMock();
|
||||
|
||||
$mockResponse->expects($this->once())
|
||||
->method('disable');
|
||||
|
||||
$mockResponse->expects($this->any())
|
||||
->method('headersSent')
|
||||
->with()
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$attrInstance = new ReflectionProperty('PMA\libraries\Response', '_instance');
|
||||
$attrInstance->setAccessible(true);
|
||||
$attrInstance->setValue($mockResponse);
|
||||
$this->mockResponse();
|
||||
|
||||
PMA_sendHeaderLocation($testUri);
|
||||
|
||||
$attrInstance->setValue($restoreInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user