diff --git a/Tests/Functional/Controller/JMSController.php b/Tests/Functional/Controller/JMSController.php new file mode 100644 index 000000000..11788606b --- /dev/null +++ b/Tests/Functional/Controller/JMSController.php @@ -0,0 +1,30 @@ += 80100) { + /** + * @Route(host="api.example.com") + */ + class JMSController extends JMSController81 + { + } +} else { + /** + * @Route(host="api.example.com") + */ + class JMSController extends JMSController80 + { + } +} diff --git a/Tests/Functional/Controller/JMSController81.php b/Tests/Functional/Controller/JMSController81.php new file mode 100644 index 000000000..b81ca9a5c --- /dev/null +++ b/Tests/Functional/Controller/JMSController81.php @@ -0,0 +1,26 @@ +getModel('JMSNamingStrategyConstraints')->toJson(), true)); } + /** + * @requires PHP >= 8.1 + */ + public function testEnumSupport() + { + $this->assertEquals([ + 'type' => 'object', + 'properties' => [ + 'id' => [ + 'type' => 'integer', + ], + 'type' => [ + '$ref' => '#/components/schemas/ArticleType81', + ], + ], + 'schema' => 'Article81', + ], json_decode($this->getModel('Article81')->toJson(), true)); + + $this->assertEquals([ + 'schema' => 'ArticleType81', + 'type' => 'string', + 'enum' => [ + 'draft', + 'final', + ], + ], json_decode($this->getModel('ArticleType81')->toJson(), true)); + } + protected static function createKernel(array $options = []): KernelInterface { return new TestKernel(TestKernel::USE_JMS); diff --git a/Tests/Functional/TestKernel.php b/Tests/Functional/TestKernel.php index d2aa13978..286852618 100644 --- a/Tests/Functional/TestKernel.php +++ b/Tests/Functional/TestKernel.php @@ -310,6 +310,12 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load ], ]); + if ($this->flags & self::USE_JMS && \PHP_VERSION_ID >= 80100) { + $c->loadFromExtension('jms_serializer', [ + 'enum_support' => true, + ]); + } + $def = new Definition(VirtualTypeClassDoesNotExistsHandlerDefinedDescriber::class); $def->addTag('nelmio_api_doc.model_describer'); $c->setDefinition('nelmio.test.jms.virtual_type.describer', $def);