This commit is contained in:
Guilhem Niot 2022-09-25 21:47:11 +02:00
parent cf8635eb95
commit 2862d8cf6f
5 changed files with 16 additions and 12 deletions

View File

@ -36,7 +36,6 @@ jobs:
symfony-require: "5.4.*" symfony-require: "5.4.*"
- php-version: 8.1 - php-version: 8.1
symfony-require: "6.0.*" symfony-require: "6.0.*"
api-platform: "early"
steps: steps:
- name: "Checkout" - name: "Checkout"

View File

@ -12,9 +12,11 @@
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity; namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
use ApiPlatform\Core\Annotation\ApiProperty; use ApiPlatform\Core\Annotation\ApiProperty;
use Nelmio\ApiDocBundle\Tests\Functional\EntityExcluded;
// BC Api-Platform < 3.x
if (!class_exists(ApiProperty::class)) { if (!class_exists(ApiProperty::class)) {
class_alias(Dummy81::class, Dummy::class); class Dummy extends EntityExcluded\ApiPlatform3\Dummy {}
} else { } else {
class_alias(Dummy71::class, Dummy::class); class_alias(EntityExcluded\ApiPlatform2\Dummy::class, Dummy::class);
} }

View File

@ -9,17 +9,16 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity; namespace Nelmio\ApiDocBundle\Tests\Functional\EntityExcluded\ApiPlatform2;
use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
* @author Guilhem N. <egetick@gmail.com> * @author Guilhem N. <egetick@gmail.com>
* *
* @ApiResource( * @ApiResource(
* shortName="Dummy",
* collectionOperations={ * collectionOperations={
* "get"={"method"="GET"}, * "get"={"method"="GET"},
* "custom2"={"path"="/foo", "method"="GET"}, * "custom2"={"path"="/foo", "method"="GET"},
@ -28,7 +27,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* itemOperations={"get"={"method"="GET"}}) * itemOperations={"get"={"method"="GET"}})
* ) * )
*/ */
class Dummy71 class Dummy
{ {
/** /**
* @var int * @var int

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity; namespace Nelmio\ApiDocBundle\Tests\Functional\EntityExcluded\ApiPlatform3;
use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\ApiResource;
@ -23,7 +23,6 @@ use Symfony\Component\Validator\Constraints as Assert;
*/ */
#[ #[
ApiResource( ApiResource(
shortName: 'Dummy',
operations: [ operations: [
new Get(name: 'get'), new Get(name: 'get'),
new Get(name: 'custom2', uriTemplate: '/foo'), new Get(name: 'custom2', uriTemplate: '/foo'),
@ -32,7 +31,7 @@ use Symfony\Component\Validator\Constraints as Assert;
], ],
) )
] ]
class Dummy81 class Dummy
{ {
/** /**
* @var int * @var int

View File

@ -11,6 +11,7 @@
namespace Nelmio\ApiDocBundle\Tests\Functional; namespace Nelmio\ApiDocBundle\Tests\Functional;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Symfony\Bundle\ApiPlatformBundle; use ApiPlatform\Symfony\Bundle\ApiPlatformBundle;
use Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle; use Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle;
use FOS\RestBundle\FOSRestBundle; use FOS\RestBundle\FOSRestBundle;
@ -163,7 +164,11 @@ class TestKernel extends Kernel
]); ]);
$c->loadFromExtension('api_platform', [ $c->loadFromExtension('api_platform', [
'mapping' => ['paths' => ['%kernel.project_dir%/Tests/Functional/Entity']], 'mapping' => ['paths' => [
!class_exists(ApiProperty::class)
? '%kernel.project_dir%/Tests/Functional/EntityExcluded/ApiPlatform3'
: '%kernel.project_dir%/Tests/Functional/EntityExcluded/ApiPlatform2'
]],
]); ]);
$c->loadFromExtension('fos_rest', [ $c->loadFromExtension('fos_rest', [