|
18 | 18 | use ApiPlatform\Metadata\Parameter;
|
19 | 19 | use ApiPlatform\Metadata\Parameters;
|
20 | 20 | use ApiPlatform\Metadata\QueryParameter;
|
| 21 | +use ApiPlatform\State\ParameterNotFound; |
21 | 22 | use ApiPlatform\State\ParameterProviderInterface;
|
22 | 23 | use ApiPlatform\State\Provider\ParameterProvider;
|
23 | 24 | use PHPUnit\Framework\TestCase;
|
@@ -51,16 +52,20 @@ public function has(string $id): bool
|
51 | 52 | 'order' => new QueryParameter(key: 'order', provider: 'test'),
|
52 | 53 | 'search[:property]' => new QueryParameter(key: 'search[:property]', provider: [self::class, 'provide']),
|
53 | 54 | 'foo' => new QueryParameter(key: 'foo', provider: [self::class, 'shouldNotBeCalled']),
|
| 55 | + 'baz' => (new QueryParameter(key: 'baz'))->withExtraProperties(['_api_values' => 'test1']), |
| 56 | + 'fas' => (new QueryParameter(key: 'fas'))->withExtraProperties(['_api_values' => '42']), |
54 | 57 | ]));
|
55 | 58 | $parameterProvider = new ParameterProvider(null, $locator);
|
56 |
| - $request = new Request(server: ['QUERY_STRING' => 'order[foo]=asc&search[a]=bar']); |
| 59 | + $request = new Request(server: ['QUERY_STRING' => 'order[foo]=asc&search[a]=bar&baz=t42']); |
57 | 60 | $context = ['request' => $request, 'operation' => $operation];
|
58 | 61 | $parameterProvider->provide($operation, [], $context);
|
59 | 62 | $operation = $request->attributes->get('_api_operation');
|
60 | 63 |
|
61 | 64 | $this->assertEquals('ok', $operation->getName());
|
62 | 65 | $this->assertEquals(['foo' => 'asc'], $operation->getParameters()->get('order', QueryParameter::class)->getValue());
|
63 | 66 | $this->assertEquals(['a' => 'bar'], $operation->getParameters()->get('search[:property]', QueryParameter::class)->getValue());
|
| 67 | + $this->assertEquals('t42', $operation->getParameters()->get('baz', QueryParameter::class)->getValue()); |
| 68 | + $this->assertEquals(new ParameterNotFound(), $operation->getParameters()->get('fas', QueryParameter::class)->getValue()); |
64 | 69 | }
|
65 | 70 |
|
66 | 71 | public static function provide(): void
|
|
0 commit comments