mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
unit tests for ParameterParser::hasSetAny
This commit is contained in:
@@ -119,10 +119,10 @@ class ParameterParser
|
|||||||
return $aLangPrefOrder;
|
return $aLangPrefOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasSetAny($aParams)
|
public function hasSetAny($aParamNames)
|
||||||
{
|
{
|
||||||
foreach ($aParams as $sParam) {
|
foreach ($aParamNames as $sName) {
|
||||||
if ($this->getBool($sParam)) {
|
if ($this->getBool($sName)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,4 +246,22 @@ class ParameterParserTest extends \PHPUnit\Framework\TestCase
|
|||||||
'type' => 'type',
|
'type' => 'type',
|
||||||
), $oParams->getPreferredLanguages('default'));
|
), $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')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user