From 77bbca02003db970a73f4261af79e7616180eb96 Mon Sep 17 00:00:00 2001 From: djordy Date: Thu, 24 Oct 2024 23:13:57 +0200 Subject: [PATCH] test updates --- tests/Functional/BazingaFunctionalTest.php | 5 --- .../EntityExcluded/BazingaUserTyped.php | 30 ++++++++-------- .../EntityExcluded/SerializedNameEnt.php | 36 ------------------- tests/Functional/FunctionalTest.php | 11 +----- tests/Functional/TestKernel.php | 7 ---- .../SymfonyConstraintAnnotationReaderTest.php | 4 --- 6 files changed, 15 insertions(+), 78 deletions(-) delete mode 100644 tests/Functional/EntityExcluded/SerializedNameEnt.php diff --git a/tests/Functional/BazingaFunctionalTest.php b/tests/Functional/BazingaFunctionalTest.php index 9d7cecfdb..06eedbe96 100644 --- a/tests/Functional/BazingaFunctionalTest.php +++ b/tests/Functional/BazingaFunctionalTest.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\Tests\Functional; -use Hateoas\Configuration\Embedded; use Metadata\Cache\PsrCacheAdapter; use Metadata\MetadataFactory; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -109,10 +108,6 @@ public function testWithGroup(): void public function testWithType(): void { - if (!method_exists(Embedded::class, 'getType')) { - self::markTestSkipped('Typed embedded properties require at most willdurand/hateoas 3.0'); - } - self::assertEquals([ 'type' => 'object', 'properties' => [ diff --git a/tests/Functional/EntityExcluded/BazingaUserTyped.php b/tests/Functional/EntityExcluded/BazingaUserTyped.php index 82c6c1410..f5362cb75 100644 --- a/tests/Functional/EntityExcluded/BazingaUserTyped.php +++ b/tests/Functional/EntityExcluded/BazingaUserTyped.php @@ -13,22 +13,20 @@ use Hateoas\Configuration\Annotation as Hateoas; -/** - * @Hateoas\Relation( - * name="typed_bazinga_users", - * embedded=@Hateoas\Embedded( - * "expr(service('zz'))", - * type="array" - * ) - * ) - * @Hateoas\Relation( - * name="typed_bazinga_name", - * embedded=@Hateoas\Embedded( - * "expr(service('yy'))", - * type="string" - * ) - * ) - */ +#[Hateoas\Relation( + name: 'typed_bazinga_users', + embedded: new Hateoas\Embedded( + content: "expr(service('zz'))", + type: "array" + ) +)] +#[Hateoas\Relation( + name: 'typed_bazinga_name', + embedded: new Hateoas\Embedded( + content: "expr(service('yy'))", + type: 'string' + ) +)] class BazingaUserTyped { } diff --git a/tests/Functional/EntityExcluded/SerializedNameEnt.php b/tests/Functional/EntityExcluded/SerializedNameEnt.php deleted file mode 100644 index a7dc45925..000000000 --- a/tests/Functional/EntityExcluded/SerializedNameEnt.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ -class SerializedNameEnt -{ - /** - * @SerializedName("notfoo") - * - * @var string - */ - public $foo; - - /** - * Tests serialized name feature. - * - * @SerializedName("notwhatyouthink") - */ - public function setBar(string $bar) - { - } -} diff --git a/tests/Functional/FunctionalTest.php b/tests/Functional/FunctionalTest.php index 404929ec7..c31394daf 100644 --- a/tests/Functional/FunctionalTest.php +++ b/tests/Functional/FunctionalTest.php @@ -17,7 +17,6 @@ use OpenApi\Attributes as OAAttributes; use OpenApi\Generator; use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\Serializer\Annotation\SerializedName; class FunctionalTest extends WebTestCase { @@ -587,15 +586,7 @@ public function testNoDuplicatedParameters(): void public function testSerializedNameAction(): void { - if (!class_exists(SerializedName::class)) { - self::markTestSkipped('Annotation @SerializedName doesn\'t exist.'); - } - - if (TestKernel::isAttributesAvailable()) { - $model = $this->getModel('SerializedNameEntity'); - } else { - $model = $this->getModel('SerializedNameEnt'); - } + $model = $this->getModel('SerializedNameEntity'); self::assertCount(2, $model->properties); diff --git a/tests/Functional/TestKernel.php b/tests/Functional/TestKernel.php index 407fe797a..0c2c6cbec 100644 --- a/tests/Functional/TestKernel.php +++ b/tests/Functional/TestKernel.php @@ -15,7 +15,6 @@ use ApiPlatform\Symfony\Bundle\ApiPlatformBundle; use Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle; use FOS\RestBundle\FOSRestBundle; -use Hateoas\Configuration\Embedded; use JMS\SerializerBundle\JMSSerializerBundle; use Nelmio\ApiDocBundle\NelmioApiDocBundle; use Nelmio\ApiDocBundle\Render\Html\AssetsMode; @@ -91,12 +90,6 @@ protected function configureRoutes(RoutingConfigurator $routes): void if (self::USE_BAZINGA === $this->flag) { $routes->withPath('/')->import(__DIR__.'/Controller/BazingaTypedController.php', self::isAnnotationsAvailable() ? 'annotation' : 'attribute'); - - try { - new \ReflectionMethod(Embedded::class, 'getType'); - $routes->withPath('/')->import(__DIR__.'/Controller/BazingaTypedController.php', self::isAnnotationsAvailable() ? 'annotation' : 'attribute'); - } catch (\ReflectionException $e) { - } } if (self::USE_FOSREST === $this->flag) { diff --git a/tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php b/tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php index f574c8b4e..abb97b745 100644 --- a/tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php +++ b/tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php @@ -54,10 +54,6 @@ public function testUpdatePropertyFix1283(): void */ public function testOptionalProperty($entity): void { - if (!\property_exists(Assert\NotBlank::class, 'allowNull')) { - self::markTestSkipped('NotBlank::allowNull was added in symfony/validator 4.3.'); - } - $schema = $this->createObj(OA\Schema::class, []); $schema->merge([$this->createObj(OA\Property::class, ['property' => 'property1'])]); $schema->merge([$this->createObj(OA\Property::class, ['property' => 'property2'])]);