diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-01-12 14:15:12 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-01-17 09:51:31 +0100 |
commit | 4ef302c0be2047f78b1aa3976eba003a2c280f64 (patch) | |
tree | 51b5c301126eebc6d6db91095e8cc7f2166b3324 /tests/lib | |
parent | 22b3280ac2b60e52049a07ada007768e3cef05ed (diff) | |
download | nextcloud-server-4ef302c0be2047f78b1aa3976eba003a2c280f64.tar.gz nextcloud-server-4ef302c0be2047f78b1aa3976eba003a2c280f64.zip |
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 <hey@morrisjobke.de>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/L10N/FactoryTest.php | 15 |
1 files changed, 11 insertions, 4 deletions
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') |