$bag =
new ParameterBag(['foo' => 'bar'
]);
$this->
assertTrue($bag->
has('foo'
), '->has() returns true if a parameter is defined'
);
$this->
assertFalse($bag->
has('unknown'
), '->has() return false if a parameter is not defined'
);
} public function testGetAlpha() { $bag =
new ParameterBag(['word' => 'foo_BAR_012', 'bool' => true, 'integer' => 123
]);
$this->
assertSame('fooBAR',
$bag->
getAlpha('word'
), '->getAlpha() gets only alphabetic characters'
);
$this->
assertSame('',
$bag->
getAlpha('unknown'
), '->getAlpha() returns empty string if a parameter is not defined'
);
$this->
assertSame('abcDEF',
$bag->
getAlpha('unknown', 'abc_DEF_012'
), '->getAlpha() returns filtered default if a parameter is not defined'
);
$this->
assertSame('',
$bag->
getAlpha('integer', 'abc_DEF_012'
), '->getAlpha() returns empty string if a parameter is an integer'
);
$this->
assertSame('',
$bag->
getAlpha('bool', 'abc_DEF_012'
), '->getAlpha() returns empty string if a parameter is a boolean'
);
} public function testGetAlphaExceptionWithArray() { $bag =
new ParameterBag(['word' =>
['foo_BAR_012'
]]);
$this->
expectException(UnexpectedValueException::
class);