diff --git a/tests/Fixtures/TestBundle/ApiResource/OperationPriorities.php b/tests/Fixtures/TestBundle/ApiResource/OperationPriorities.php new file mode 100644 index 0000000000..47cc7ef4e2 --- /dev/null +++ b/tests/Fixtures/TestBundle/ApiResource/OperationPriorities.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource; + +use ApiPlatform\Metadata\Get; + +#[Get(name: 'a', priority: -1, uriTemplate: 'operation_priority/{id}', provider: [self::class, 'shouldNotBeCalled'])] +#[Get(name: 'b', priority: 1, uriTemplate: 'operation_priority/{id}', provider: [self::class, 'shouldBeCalled'])] +class OperationPriorities +{ + public int $id = 1; + + public static function shouldBeCalled(): self + { + return new self(); + } + + public static function shouldNotBeCalled(): self + { + throw new \Exception('fail'); + } +} diff --git a/tests/Symfony/Bundle/Test/ApiTestCaseTest.php b/tests/Symfony/Bundle/Test/ApiTestCaseTest.php index b236a1d03d..9102490789 100644 --- a/tests/Symfony/Bundle/Test/ApiTestCaseTest.php +++ b/tests/Symfony/Bundle/Test/ApiTestCaseTest.php @@ -267,6 +267,17 @@ public function testFindIriBy(): void $this->assertNull(self::findIriBy($resource, ['name' => 'not-exist'])); } + public function testGetPrioritizedOperation(): void + { + $r = self::createClient()->request('GET', '/operation_priority/1', [ + 'headers' => [ + 'accept' => 'application/ld+json', + ], + ]); + $this->assertResponseIsSuccessful(); + dd($r->toArray()); + } + /** * @group mercure */