Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/OpenApi/Tests/Factory/OpenApiFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1501,11 +1501,11 @@ public function testMetadataParameterInOpenApiOperationParametersThrows(): void

public function testStringFilterWithUserDescriptionOverridesFilterDescription(): void
{
$filterLocator = $this->createMock(ContainerInterface::class);
$filterLocator->method('has')->with('f1')->willReturn(true);
$filterLocator->method('get')->with('f1')->willReturn(new DummyFilter([
$filterLocator = $this->createStub(ContainerInterface::class);
$filterLocator->method('has')->willReturnMap([['f1', true]]);
$filterLocator->method('get')->willReturnMap([['f1', new DummyFilter([
'name' => ['property' => 'name', 'type' => 'string', 'required' => true, 'strategy' => 'exact'],
]));
])]]);

$parameters = $this->getGeneratedQueryParameters(
['name' => new QueryParameter(filter: 'f1', description: 'User description wins')],
Expand All @@ -1517,11 +1517,11 @@ public function testStringFilterWithUserDescriptionOverridesFilterDescription():

public function testStringFilterWithUserOpenApiOverridesFilterOpenApi(): void
{
$filterLocator = $this->createMock(ContainerInterface::class);
$filterLocator->method('has')->with('f2')->willReturn(true);
$filterLocator->method('get')->with('f2')->willReturn(new DummyFilter([
$filterLocator = $this->createStub(ContainerInterface::class);
$filterLocator->method('has')->willReturnMap([['f2', true]]);
$filterLocator->method('get')->willReturnMap([['f2', new DummyFilter([
'name' => ['property' => 'name', 'type' => 'string'],
]));
])]]);

$parameters = $this->getGeneratedQueryParameters(
['name' => new QueryParameter(filter: 'f2', openApi: new Parameter(name: 'name', in: 'query', description: 'User OpenApi description', deprecated: true, example: 'foo'))],
Expand Down Expand Up @@ -1550,12 +1550,12 @@ public function testFilterInstanceWithUserMetadataStillHonoured(): void

public function testStringFilterFanOutOnlyOverridesTheMatchingGeneratedParameter(): void
{
$filterLocator = $this->createMock(ContainerInterface::class);
$filterLocator->method('has')->with('f4fanout')->willReturn(true);
$filterLocator->method('get')->with('f4fanout')->willReturn(new DummyFilter([
$filterLocator = $this->createStub(ContainerInterface::class);
$filterLocator->method('has')->willReturnMap([['f4fanout', true]]);
$filterLocator->method('get')->willReturnMap([['f4fanout', new DummyFilter([
'name' => ['property' => 'name', 'type' => 'string'],
'description' => ['property' => 'description', 'type' => 'string'],
]));
])]]);

$parameters = $this->getGeneratedQueryParameters(
['order[name]' => new QueryParameter(filter: 'f4fanout', property: 'name', description: 'Fan-out matched description')],
Expand All @@ -1568,11 +1568,11 @@ public function testStringFilterFanOutOnlyOverridesTheMatchingGeneratedParameter

public function testStringFilterWithoutUserMetadataIsUnchanged(): void
{
$filterLocator = $this->createMock(ContainerInterface::class);
$filterLocator->method('has')->with('f5nometa')->willReturn(true);
$filterLocator->method('get')->with('f5nometa')->willReturn(new DummyFilter([
$filterLocator = $this->createStub(ContainerInterface::class);
$filterLocator->method('has')->willReturnMap([['f5nometa', true]]);
$filterLocator->method('get')->willReturnMap([['f5nometa', new DummyFilter([
'name' => ['property' => 'name', 'type' => 'string'],
]));
])]]);

$parameters = $this->getGeneratedQueryParameters(
['name' => new QueryParameter(filter: 'f5nometa')],
Expand All @@ -1590,12 +1590,12 @@ public function testStringFilterWithoutUserMetadataIsUnchanged(): void
*/
public function testStringFilterFanOutWithNoMatchLeavesGeneratedParametersUntouched(): void
{
$filterLocator = $this->createMock(ContainerInterface::class);
$filterLocator->method('has')->with('f6nomatch')->willReturn(true);
$filterLocator->method('get')->with('f6nomatch')->willReturn(new DummyFilter([
$filterLocator = $this->createStub(ContainerInterface::class);
$filterLocator->method('has')->willReturnMap([['f6nomatch', true]]);
$filterLocator->method('get')->willReturnMap([['f6nomatch', new DummyFilter([
'name' => ['property' => 'name', 'type' => 'string'],
'description' => ['property' => 'description', 'type' => 'string'],
]));
])]]);

$parameters = $this->getGeneratedQueryParameters(
['search' => new QueryParameter(filter: 'f6nomatch', description: 'Should NOT apply, no matching name')],
Expand Down Expand Up @@ -1631,7 +1631,7 @@ private function getGeneratedQueryParameters(array $parameters, ?ContainerInterf
$resourceCollectionMetadataFactory = $this->createMock(ResourceMetadataCollectionFactoryInterface::class);
$propertyNameCollectionFactory = $this->createMock(PropertyNameCollectionFactoryInterface::class);
$propertyMetadataFactory = $this->createMock(PropertyMetadataFactoryInterface::class);
$definitionNameFactory = new DefinitionNameFactory([]);
$definitionNameFactory = new DefinitionNameFactory();

$resourceCollectionMetadata = new ResourceMetadataCollection(Dummy::class, [(new ApiResource(operations: [
(new GetCollection())
Expand Down
Loading