Skip to content

Commit

Permalink
minor FriendsOfSymfony#2076 use deprecation-free TwigBundle config in…
Browse files Browse the repository at this point in the history
… tests (xabbuh)

This PR was merged into the 2.x branch.

Discussion
----------

use deprecation-free TwigBundle config in tests

Commits
-------

7dc0f6a use deprecation-free TwigBundle config in tests
  • Loading branch information
xabbuh committed Feb 1, 2020
2 parents 42bdfed + 7dc0f6a commit f651328
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 7 deletions.
18 changes: 16 additions & 2 deletions Tests/Functional/RequestBodyParamConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace FOS\RestBundle\Tests\Functional;

use Symfony\Bundle\FrameworkBundle\Test\BrowserKitAssertionsTrait;
use Symfony\Bundle\TwigBundle\Controller\PreviewErrorController;

class RequestBodyParamConverterTest extends WebTestCase
Expand Down Expand Up @@ -40,17 +41,30 @@ public function testRequestBodyIsDeserialized()
*
* @see https://github.com/FriendsOfSymfony/FOSRestBundle/issues/1237
*/
public function testTwigErrorPage()
public function testErrorPageServedByTwigBundle()
{
if (!class_exists(PreviewErrorController::class)) {
$this->markTestSkipped();
}

$client = $this->createClient(['test_case' => 'RequestBodyParamConverter']);
$client = $this->createClient(['test_case' => 'RequestBodyParamConverterTwigBundle']);
$client->request('GET', '/_error/404.txt');

// Status code 200 as this page describes an error but is not the result of an error.
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertContains('The server returned a "404 Not Found".', $client->getResponse()->getContent());
}

public function testErrorPageServedByFrameworkBundle()
{
if (!trait_exists(BrowserKitAssertionsTrait::class)) {
$this->markTestSkipped();
}

$client = $this->createClient(['test_case' => 'RequestBodyParamConverterFrameworkBundle']);
$client->request('GET', '/_error/404.txt');

$this->assertEquals(404, $client->getResponse()->getStatusCode());
$this->assertContains('The server returned a "404 Not Found".', $client->getResponse()->getContent());
}
}
1 change: 1 addition & 0 deletions Tests/Functional/app/ConfigurationWithTwig/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ web_profiler:
toolbar: false

twig:
exception_controller: ~
strict_variables: '%kernel.debug%'
1 change: 0 additions & 1 deletion Tests/Functional/app/RequestBodyParamConverter/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \FOS\RestBundle\FOSRestBundle(),
new \FOS\RestBundle\Tests\Functional\Bundle\TestBundle\TestBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
Expand Down
5 changes: 1 addition & 4 deletions Tests/Functional/app/RequestBodyParamConverter/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ imports:
framework:
serializer: true
router:
resource: "%kernel.project_dir%/RequestBodyParamConverter/routing.yml"
resource: "%kernel.project_dir%/config/routing.yml"
strict_requirements: true

fos_rest:
Expand All @@ -16,9 +16,6 @@ sensio_framework_extra:
request:
converters: true

twig:
strict_variables: '%kernel.debug%'

services:
get_set_method_normalizer:
class: Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* This file is part of the FOSRestBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \FOS\RestBundle\FOSRestBundle(),
new \FOS\RestBundle\Tests\Functional\Bundle\TestBundle\TestBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/sensio_framework_extra.yml }

framework:
serializer: true
router:
resource: "%kernel.project_dir%/RequestBodyParamConverterFrameworkBundle/routing.yml"
strict_requirements: true

fos_rest:
body_converter:
enabled: true

sensio_framework_extra:
request:
converters: true

services:
get_set_method_normalizer:
class: Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer
tags:
- { name: serializer.normalizer }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
routing:
resource: "../config/routing.yml"

_errors:
resource: "@FrameworkBundle/Resources/config/routing/errors.xml"
prefix: /_error
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the FOSRestBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \FOS\RestBundle\FOSRestBundle(),
new \FOS\RestBundle\Tests\Functional\Bundle\TestBundle\TestBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/sensio_framework_extra.yml }

framework:
serializer: true
router:
resource: "%kernel.project_dir%/RequestBodyParamConverterTwigBundle/routing.yml"
strict_requirements: true

fos_rest:
body_converter:
enabled: true

sensio_framework_extra:
request:
converters: true

twig:
strict_variables: '%kernel.debug%'

services:
get_set_method_normalizer:
class: Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer
tags:
- { name: serializer.normalizer }
1 change: 1 addition & 0 deletions Tests/Functional/app/Serializer/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ fos_rest:
view_response_listener: 'force'

twig:
exception_controller: ~
strict_variables: '%kernel.debug%'
1 change: 1 addition & 0 deletions Tests/Functional/app/Version/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ fos_rest:
- query

twig:
exception_controller: ~
strict_variables: '%kernel.debug%'
1 change: 1 addition & 0 deletions Tests/Functional/app/ViewResponseListener/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ fos_rest:
- { path: ^/, priorities: [ html, json, xml ], fallback_format: ~, prefer_extension: true }

twig:
exception_controller: ~
strict_variables: '%kernel.debug%'

0 comments on commit f651328

Please sign in to comment.