]> git.openstreetmap.org Git - nominatim.git/commitdiff
unit tests for ParameterParser::hasSetAny
authormarc tobias <mtmail@gmx.net>
Wed, 19 Feb 2020 15:55:17 +0000 (16:55 +0100)
committermarc tobias <mtmail@gmx.net>
Wed, 19 Feb 2020 15:55:17 +0000 (16:55 +0100)
lib/ParameterParser.php
test/php/Nominatim/ParameterParserTest.php

index ae252d6795b9e6f63ff50704c163091fac8ac25a..32a848b93011fce3edaa1975ad6450369b121725 100644 (file)
@@ -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;
             }
         }
index 75f6b276ae19fd5bcd143f399016fff36742a97e..361fefc1c8f15ecb35a9255bc537ae3fdc02511f 100644 (file)
@@ -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')));
+    }
 }