$this->
expectException(UnexpectedValueException::
class);
$this->
expectExceptionMessage('Parameter value "word" cannot be converted to "string".'
);
$bag->
getDigits('word'
);
} public function testGetInt() { $bag =
new ParameterBag(['digits' => '123', 'bool' => true
]);
$this->
assertSame(123,
$bag->
getInt('digits', 0
), '->getInt() gets a value of parameter as integer'
);
$this->
assertSame(0,
$bag->
getInt('unknown', 0
), '->getInt() returns zero if a parameter is not defined'
);
$this->
assertSame(10,
$bag->
getInt('unknown', 10
), '->getInt() returns the default if a parameter is not defined'
);
$this->
assertSame(1,
$bag->
getInt('bool', 0
), '->getInt() returns 1 if a parameter is true'
);
} /**
* @group legacy
*/
public function testGetIntExceptionWithArray() { $this->
expectDeprecation(sprintf('Since symfony/http-foundation 6.3: Ignoring invalid values when using "%s::getInt(\'digits\')" is deprecated and will throw an "%s" in 7.0; use method "filter()" with flag "FILTER_NULL_ON_FAILURE" to keep ignoring them.', ParameterBag::
class, UnexpectedValueException::
class));