$this->
expectException(UnexpectedValueException::
class);
$this->
expectExceptionMessage('Parameter value "word" cannot be converted to "string".'
);
$bag->
getAlpha('word'
);
} public function testGetAlnum() { $bag =
new ParameterBag(['word' => 'foo_BAR_012', 'bool' => true, 'integer' => 123
]);
$this->
assertSame('fooBAR012',
$bag->
getAlnum('word'
), '->getAlnum() gets only alphanumeric characters'
);
$this->
assertSame('',
$bag->
getAlnum('unknown'
), '->getAlnum() returns empty string if a parameter is not defined'
);
$this->
assertSame('abcDEF012',
$bag->
getAlnum('unknown', 'abc_DEF_012'
), '->getAlnum() returns filtered default if a parameter is not defined'
);
$this->
assertSame('123',
$bag->
getAlnum('integer', 'abc_DEF_012'
), '->getAlnum() returns the number as string if a parameter is an integer'
);
$this->
assertSame('1',
$bag->
getAlnum('bool', 'abc_DEF_012'
), '->getAlnum() returns 1 if a parameter is true'
);
} public function testGetAlnumExceptionWithArray() { $bag =
new ParameterBag(['word' =>
['foo_BAR_012'
]]);
$this->
expectException(UnexpectedValueException::
class);