Skip to content

Commit

Permalink
Add Swagger DocumentationNormalizer test for array collection filters (
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandoraaa authored and alanpoulain committed Oct 6, 2018
1 parent 1484962 commit 6d6b7ef
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions tests/Swagger/Serializer/DocumentationNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1229,14 +1229,21 @@ public function testFilters()
'required' => false,
'strategy' => 'partial',
]]),
'f3' => new DummyFilter(['toto' => [
'property' => 'name',
'type' => 'array',
'is_collection' => true,
'required' => true,
'strategy' => 'exact',
]]),
];

foreach ($filters as $filterId => $filter) {
$filterLocatorProphecy->has($filterId)->willReturn(true)->shouldBeCalled();
$filterLocatorProphecy->get($filterId)->willReturn($filter)->shouldBeCalled();
}

$filterLocatorProphecy->has('f3')->willReturn(false)->shouldBeCalled();
$filterLocatorProphecy->has('f4')->willReturn(false)->shouldBeCalled();

$this->normalizeWithFilters($filterLocatorProphecy->reveal());
}
Expand All @@ -1261,6 +1268,13 @@ public function testFiltersWithDeprecatedFilterCollection()
'required' => false,
'strategy' => 'partial',
]]),
'f3' => new DummyFilter(['toto' => [
'property' => 'name',
'type' => 'array',
'is_collection' => true,
'required' => true,
'strategy' => 'exact',
]]),
]));
}

Expand Down Expand Up @@ -1651,7 +1665,7 @@ private function normalizeWithFilters($filterLocator)
'This is a dummy.',
null,
[],
['get' => ['method' => 'GET', 'filters' => ['f1', 'f2', 'f3']]],
['get' => ['method' => 'GET', 'filters' => ['f1', 'f2', 'f3', 'f4']]],
[]
);
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand Down Expand Up @@ -1716,6 +1730,16 @@ private function normalizeWithFilters($filterLocator)
'required' => false,
'type' => 'integer',
],
[
'name' => 'toto',
'in' => 'query',
'required' => true,
'type' => 'array',
'items' => [
'type' => 'string',
],
'collectionFormat' => 'csv',
],
[
'name' => 'page',
'in' => 'query',
Expand Down

0 comments on commit 6d6b7ef

Please sign in to comment.