diff --git a/.travis.yml b/.travis.yml index 754c0c6..c3ddb59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,6 @@ matrix: before_install: - phpenv config-rm xdebug.ini || true - - if [ "$SYMFONY_VERSION" == "^5.0" ]; then composer remove friendsofsymfony/rest-bundle --dev; fi; - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --dev --no-update; fi; install: composer update --no-interaction $COMPOSER_FLAGS diff --git a/Tests/Functional/FOSRestTest.php b/Tests/Functional/FOSRestTest.php index 4cf601b..8ddf255 100644 --- a/Tests/Functional/FOSRestTest.php +++ b/Tests/Functional/FOSRestTest.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\Tests\Functional; -use FOS\RestBundle\FOSRestBundle; use OpenApi\Annotations as OA; class FOSRestTest extends WebTestCase @@ -25,10 +24,6 @@ class FOSRestTest extends WebTestCase public function testFOSRestAction() { - if (!class_exists(FOSRestBundle::class)) { - $this->markTestSkipped('FOSRestBundle is not installed.'); - } - $operation = $this->getOperation('/api/fosrest', 'post'); $this->assertHasParameter('foo', 'query', $operation); diff --git a/Tests/Functional/TestKernel.php b/Tests/Functional/TestKernel.php index 993d46b..8f5c7a7 100644 --- a/Tests/Functional/TestKernel.php +++ b/Tests/Functional/TestKernel.php @@ -58,12 +58,9 @@ class TestKernel extends Kernel new ApiPlatformBundle(), new NelmioApiDocBundle(), new TestBundle(), + new FOSRestBundle(), ]; - if (class_exists(FOSRestBundle::class)) { - $bundles[] = new FOSRestBundle(); - } - if ($this->useJMS) { $bundles[] = new JMSSerializerBundle(); @@ -87,15 +84,12 @@ class TestKernel extends Kernel $routes->import('', '/api', 'api_platform'); $routes->add('/docs/{area}', 'nelmio_api_doc.controller.swagger_ui')->setDefault('area', 'default'); $routes->add('/docs.json', 'nelmio_api_doc.controller.swagger'); + $routes->import(__DIR__.'/Controller/FOSRestController.php', '/', 'annotation'); if (class_exists(SerializedName::class)) { $routes->import(__DIR__.'/Controller/SerializedNameController.php', '/', 'annotation'); } - if (class_exists(FOSRestBundle::class)) { - $routes->import(__DIR__.'/Controller/FOSRestController.php', '/', 'annotation'); - } - if ($this->useJMS) { $routes->import(__DIR__.'/Controller/JMSController.php', '/', 'annotation'); } @@ -134,6 +128,7 @@ class TestKernel extends Kernel $c->loadFromExtension('twig', [ 'strict_variables' => '%kernel.debug%', + 'exception_controller' => null, ]); $c->loadFromExtension('sensio_framework_extra', [ @@ -146,16 +141,27 @@ class TestKernel extends Kernel 'mapping' => ['paths' => ['%kernel.project_dir%/Tests/Functional/Entity']], ]); - if (class_exists(FOSRestBundle::class)) { - $c->loadFromExtension('fos_rest', [ - 'format_listener' => [ - 'rules' => [ - [ - 'path' => '^/', - 'fallback_format' => 'json', - ], + $c->loadFromExtension('fos_rest', [ + 'format_listener' => [ + 'rules' => [ + [ + 'path' => '^/', + 'fallback_format' => 'json', ], ], + ], + ]); + + // If FOSRestBundle 2.8 + if (class_exists(\FOS\RestBundle\EventListener\ResponseStatusCodeListener::class)) { + $c->loadFromExtension('fos_rest', [ + 'exception' => [ + 'enabled' => false, + 'exception_listener' => false, + 'serialize_exceptions' => false, + ], + 'body_listener' => false, + 'routing_loader' => false, ]); } diff --git a/composer.json b/composer.json index c48f661..b8cf0db 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "doctrine/common": "^2.4", "api-platform/core": "^2.4", - "friendsofsymfony/rest-bundle": "^2.0", + "friendsofsymfony/rest-bundle": "^2.0|^3.0@beta", "willdurand/hateoas-bundle": "^1.0|^2.0", "jms/serializer-bundle": "^2.3|^3.0", "jms/serializer": "^1.14|^3.0"