Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-01-12 16:15:12 +0300
committerMorris Jobke <hey@morrisjobke.de>2018-01-17 11:51:31 +0300
commit4ef302c0be2047f78b1aa3976eba003a2c280f64 (patch)
tree51b5c301126eebc6d6db91095e8cc7f2166b3324 /tests/lib/L10N
parent22b3280ac2b60e52049a07ada007768e3cef05ed (diff)
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/L10N')
-rw-r--r--tests/lib/L10N/FactoryTest.php15
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')