diff --git a/src/ParameterValidator/Tests/ParameterValueExtractorTest.php b/src/ParameterValidator/Tests/ParameterValueExtractorTest.php index 310c80c432..a2e22e7b9b 100644 --- a/src/ParameterValidator/Tests/ParameterValueExtractorTest.php +++ b/src/ParameterValidator/Tests/ParameterValueExtractorTest.php @@ -87,4 +87,45 @@ public function provideGetSeparatorCases(): iterable ]; } } + + /** + * @dataProvider provideGetValueCases + * + * @param int[]|string[] $expectedValue + * @param int|int[]|string|string[] $value + */ + public function testGetValue(array $expectedValue, int|string|array $value, string $collectionFormat): void + { + self::assertSame($expectedValue, ParameterValueExtractor::getValue($value, $collectionFormat)); + } + + /** + * @return iterable + */ + public function provideGetValueCases(): iterable + { + yield 'empty input' => [ + [], [], 'csv', + ]; + + yield 'comma separated value' => [ + ['foo', 'bar'], 'foo,bar', 'csv', + ]; + + yield 'space separated value' => [ + ['foo', 'bar'], 'foo bar', 'ssv', + ]; + + yield 'tab separated value' => [ + ['foo', 'bar'], 'foo\tbar', 'tsv', + ]; + + yield 'pipe separated value' => [ + ['foo', 'bar'], 'foo|bar', 'pipes', + ]; + + yield 'array values' => [ + ['foo', 'bar'], ['foo', 'bar'], 'csv', + ]; + } }