Use shared mock for response without any header

Fixes #12079

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2017-01-18 16:05:32 +01:00
parent ffb28560c7
commit ce9f84e477
2 changed files with 12 additions and 29 deletions

View File

@ -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');

View File

@ -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);
}
}
}