From: marc tobias Date: Wed, 19 Feb 2020 15:55:17 +0000 (+0100) Subject: unit tests for ParameterParser::hasSetAny X-Git-Tag: v3.5.0~75^2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/7fd9d0eeef8efafa8b5ab5bc15d73c3c31c160e6?hp=d35a0b392e5031bb5bbdcb5d32ca25306568d29a unit tests for ParameterParser::hasSetAny --- diff --git a/lib/ParameterParser.php b/lib/ParameterParser.php index ae252d67..32a848b9 100644 --- a/lib/ParameterParser.php +++ b/lib/ParameterParser.php @@ -119,10 +119,10 @@ class ParameterParser return $aLangPrefOrder; } - public function hasSetAny($aParams) + public function hasSetAny($aParamNames) { - foreach ($aParams as $sParam) { - if ($this->getBool($sParam)) { + foreach ($aParamNames as $sName) { + if ($this->getBool($sName)) { return true; } } diff --git a/test/php/Nominatim/ParameterParserTest.php b/test/php/Nominatim/ParameterParserTest.php index 75f6b276..361fefc1 100644 --- a/test/php/Nominatim/ParameterParserTest.php +++ b/test/php/Nominatim/ParameterParserTest.php @@ -246,4 +246,22 @@ class ParameterParserTest extends \PHPUnit\Framework\TestCase 'type' => 'type', ), $oParams->getPreferredLanguages('default')); } + + public function testHasSetAny() + { + $oParams = new ParameterParser(array( + 'one' => '', + 'two' => 0, + 'three' => '0', + 'four' => '1', + 'five' => 'anystring' + )); + $this->assertFalse($oParams->hasSetAny(array())); + $this->assertFalse($oParams->hasSetAny(array(''))); + $this->assertFalse($oParams->hasSetAny(array('unknown'))); + $this->assertFalse($oParams->hasSetAny(array('one', 'two', 'three'))); + $this->assertTrue($oParams->hasSetAny(array('one', 'four'))); + $this->assertTrue($oParams->hasSetAny(array('four'))); + $this->assertTrue($oParams->hasSetAny(array('five'))); + } }