From 4ef302c0be2047f78b1aa3976eba003a2c280f64 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 12 Jan 2018 14:15:12 +0100 Subject: Request->getHeader() should always return a string PHPDoc (of the public API) says that this method returns string but it also returns null, which is not allowed in some method calls. This fixes that behaviour and returns an empty string and fixes all code paths that explicitly checked for null to be still compliant. Found while enabling the strict_typing for lib/private for the PHP7+ migration. Signed-off-by: Morris Jobke --- tests/lib/L10N/FactoryTest.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'tests/lib/L10N') diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php index 602967b1626..4f31784337a 100644 --- a/tests/lib/L10N/FactoryTest.php +++ b/tests/lib/L10N/FactoryTest.php @@ -55,9 +55,16 @@ class FactoryTest extends TestCase { /** * @param array $methods + * @param bool $mockRequestGetHeaderMethod * @return Factory|\PHPUnit_Framework_MockObject_MockObject */ - protected function getFactory(array $methods = []) { + protected function getFactory(array $methods = [], $mockRequestGetHeaderMethod = false) { + if ($mockRequestGetHeaderMethod) { + $this->request->expects($this->any()) + ->method('getHeader') + ->willReturn(''); + } + if (!empty($methods)) { return $this->getMockBuilder(Factory::class) ->setConstructorArgs([ @@ -137,7 +144,7 @@ class FactoryTest extends TestCase { } public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStoredUserLanguage() { - $factory = $this->getFactory(['languageExists']); + $factory = $this->getFactory(['languageExists'], true); $this->invokePrivate($factory, 'requestLanguage', ['de']); $factory->expects($this->at(0)) ->method('languageExists') @@ -180,7 +187,7 @@ class FactoryTest extends TestCase { } public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStoredUserLanguageAndNotExistingDefault() { - $factory = $this->getFactory(['languageExists']); + $factory = $this->getFactory(['languageExists'], true); $this->invokePrivate($factory, 'requestLanguage', ['de']); $factory->expects($this->at(0)) ->method('languageExists') @@ -226,7 +233,7 @@ class FactoryTest extends TestCase { } public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStoredUserLanguageAndNotExistingDefaultAndNoAppInScope() { - $factory = $this->getFactory(['languageExists']); + $factory = $this->getFactory(['languageExists'], true); $this->invokePrivate($factory, 'requestLanguage', ['de']); $factory->expects($this->at(0)) ->method('languageExists') -- cgit v1.2.3