$this->
expectException(BadRequestException::
class);
$this->
expectExceptionMessage('Input value "foo" contains an array, but "FILTER_REQUIRE_ARRAY" or "FILTER_FORCE_ARRAY" flags were not set.'
);
$bag =
new InputBag(['foo' =>
['bar', 'baz'
]]);
$bag->
filter('foo', \FILTER_VALIDATE_INT
);
} public function testGetEnum() { $bag =
new InputBag(['valid-value' => 1
]);
$this->
assertSame(FooEnum::Bar,
$bag->
getEnum('valid-value', FooEnum::
class));
} public function testGetEnumThrowsExceptionWithInvalidValue() { $bag =
new InputBag(['invalid-value' => 2
]);
$this->
expectException(BadRequestException::
class);
if (\PHP_VERSION_ID >= 80200
) { $this->
expectExceptionMessage('Parameter "invalid-value" cannot be converted to enum: 2 is not a valid backing value for enum Symfony\Component\HttpFoundation\Tests\Fixtures\FooEnum.'
);
} else { $this->
expectExceptionMessage('Parameter "invalid-value" cannot be converted to enum: 2 is not a valid backing value for enum "Symfony\Component\HttpFoundation\Tests\Fixtures\FooEnum".'
);
}