From ce9f84e477fd53db65df40b33fa2d558b3a4aeed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 18 Jan 2017 16:05:32 +0100 Subject: [PATCH] Use shared mock for response without any header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #12079 Signed-off-by: Michal Čihař --- test/PMATestCase.php | 18 ++++++++------- .../core/PMA_headerLocation_test.php | 23 ++----------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/test/PMATestCase.php b/test/PMATestCase.php index 418a635f47..e949457a7f 100644 --- a/test/PMATestCase.php +++ b/test/PMATestCase.php @@ -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'); diff --git a/test/libraries/core/PMA_headerLocation_test.php b/test/libraries/core/PMA_headerLocation_test.php index 18864415a1..046acc1c06 100644 --- a/test/libraries/core/PMA_headerLocation_test.php +++ b/test/libraries/core/PMA_headerLocation_test.php @@ -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); } -} \ No newline at end of file +}