Skip to content

Commit

Permalink
minor #1972 replace deprecated code usages, drop support for Symfony …
Browse files Browse the repository at this point in the history
…< 3.4 (xabbuh)

This PR was squashed before being merged into the 2.4-dev branch (closes #1972).

Discussion
----------

replace deprecated code usages, drop support for Symfony < 3.4

Commits
-------

f9c3bcd use PHPUnit 6.5 on PHP 7.1
d4e21d2 never rely on service auto-registration
7b206d6 compatibility with symfony/form 4.2+
cea8022 fix risky tests
5526e9c fix lowest supported JMSSerializerBundle release
8e009b7 replace Controller with AbstractController
2764e00 drop support for unmaintained Symfony versions
  • Loading branch information
xabbuh committed Jan 2, 2019
2 parents ee84444 + f9c3bcd commit 5701cb9
Show file tree
Hide file tree
Showing 32 changed files with 94 additions and 76 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ matrix:
- php: 5.5
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak
- php: 5.6
# Symfony 2 LTS
- php: 7.0
env: SYMFONY_LTS='^2'
# Symfony 3 LTS
- php: 7.0
env: SYMFONY_LTS='^3'
# Symfony 4
- php: 7.1
env: SYMFONY_PHPUNIT_VERSION='6.5'
- php: 7.2
- php: 7.3
# development dependencies
Expand Down
5 changes: 5 additions & 0 deletions Form/Extension/DisableCSRFExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ public function getExtendedType()
: 'form' // SF <2.8 BC
;
}

public static function getExtendedTypes()
{
return array(FormType::class);
}
}
4 changes: 2 additions & 2 deletions Tests/EventListener/BodyListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BodyListenerTest extends TestCase
* @param string $contentType the request header content type
* @param bool $throwExceptionOnUnsupportedContentType
*
* @dataProvider testOnKernelRequestDataProvider
* @dataProvider onKernelRequestDataProvider
*/
public function testOnKernelRequest($decode, Request $request, $method, $expectedParameters, $contentType = null, $throwExceptionOnUnsupportedContentType = false)
{
Expand Down Expand Up @@ -76,7 +76,7 @@ public function testOnKernelRequest($decode, Request $request, $method, $expecte
$this->assertEquals($request->request->all(), $expectedParameters);
}

public static function testOnKernelRequestDataProvider()
public static function onKernelRequestDataProvider()
{
return [
'Empty POST request' => [true, new Request([], [], [], [], [], [], ['foo']), 'POST', ['foo'], 'application/json'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
use FOS\RestBundle\Controller\Annotations\Put;
use FOS\RestBundle\Controller\Annotations\Route;
use FOS\RestBundle\Controller\Annotations\Unlink;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use FOS\RestBundle\Tests\Fixtures\User;

class AnnotatedConditionalUsersController extends Controller
class AnnotatedConditionalUsersController extends AbstractController
{
/**
* [OPTIONS] /users.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace FOS\RestBundle\Tests\Fixtures\Controller;

use FOS\RestBundle\Controller\AbstractFOSRestController;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\FOSRestController;

/**
* @Rest\RouteResource("Article", pluralize=false)
*/
class AnnotatedNonPluralizedArticleController extends FOSRestController
class AnnotatedNonPluralizedArticleController extends AbstractFOSRestController
{
/**
* [GET] /article.
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/AnnotatedPrefixedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
namespace FOS\RestBundle\Tests\Fixtures\Controller;

use FOS\RestBundle\Controller\Annotations\Prefix;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;

/**
* @author Donald Tyler <[email protected]>
* @Prefix("aprefix")
*/
class AnnotatedPrefixedController extends Controller
class AnnotatedPrefixedController extends AbstractController
{
/**
* [GET] /aprefix/something.{_format}.
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/AnnotatedUsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
use FOS\RestBundle\Controller\Annotations\Route;
use FOS\RestBundle\Controller\Annotations\Unlink;
use FOS\RestBundle\Controller\Annotations\Unlock;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class AnnotatedUsersController extends Controller
class AnnotatedUsersController extends AbstractController
{
/**
* @Options
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/AnnotatedVersionUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

use FOS\RestBundle\Controller\Annotations\Version;
use FOS\RestBundle\Controller\Annotations\Get;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

/**
* @Version({"v1", "v3"})
*/
class AnnotatedVersionUserController extends Controller
class AnnotatedVersionUserController extends AbstractController
{
/**
* [GET, HEAD] /users/{slug}/v2.
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

use FOS\RestBundle\Controller\ControllerTrait;
use FOS\RestBundle\Routing\ClassResourceInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Validator\ConstraintViolationList;

class ArticleController extends Controller implements ClassResourceInterface
class ArticleController extends AbstractController implements ClassResourceInterface
{
use ControllerTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace FOS\RestBundle\Tests\Fixtures\Controller\Directory;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class UserTopicCommentsController extends Controller
class UserTopicCommentsController extends AbstractController
{
public function getCommentsAction($slug, $title)
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/Directory/UserTopicsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace FOS\RestBundle\Tests\Fixtures\Controller\Directory;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class UserTopicsController extends Controller
class UserTopicsController extends AbstractController
{
public function getTopicsAction($slug)
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/Directory/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace FOS\RestBundle\Tests\Fixtures\Controller\Directory;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class UsersController extends Controller
class UsersController extends AbstractController
{
public function getUsersAction()
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/InformationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

use FOS\RestBundle\Controller\ControllerTrait;
use FOS\RestBundle\Routing\ClassResourceInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class InformationController extends Controller implements ClassResourceInterface
class InformationController extends AbstractController implements ClassResourceInterface
{
use ControllerTrait;

Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

use FOS\RestBundle\Controller\ControllerTrait;
use FOS\RestBundle\Routing\ClassResourceInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class MediaController extends Controller implements ClassResourceInterface
class MediaController extends AbstractController implements ClassResourceInterface
{
use ControllerTrait;

Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/OrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace FOS\RestBundle\Tests\Fixtures\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class OrdersController extends Controller
class OrdersController extends AbstractController
{
/**
* [GET] /foos.
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\ControllerTrait;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

/**
* Class ReportController.
*/
class ReportController extends Controller
class ReportController extends AbstractController
{
use ControllerTrait;

Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/UserTopicCommentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace FOS\RestBundle\Tests\Fixtures\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class UserTopicCommentsController extends Controller
class UserTopicCommentsController extends AbstractController
{
/**
* [GET] /users/{slug}/topics/{title}/comments.
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/UserTopicsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace FOS\RestBundle\Tests\Fixtures\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class UserTopicsController extends Controller
class UserTopicsController extends AbstractController
{
/**
* [GET] /users/{slug}/topics.
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

namespace FOS\RestBundle\Tests\Fixtures\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;

class UsersController extends Controller
class UsersController extends AbstractController
{
public function copyUserAction($id)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller;

use FOS\RestBundle\Controller\AbstractFOSRestController;
use Symfony\Component\HttpFoundation\Request;
use FOS\RestBundle\Controller\Annotations\RouteResource;
use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Controller\FOSRestController;

/**
* @RouteResource("Article")
*/
class ArticleController extends FOSRestController
class ArticleController extends AbstractFOSRestController
{
/**
* Create a new resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller;

use FOS\RestBundle\Controller\AbstractFOSRestController;
use FOS\RestBundle\Controller\Annotations\FileParam;
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Controller\Annotations\RequestParam;
use FOS\RestBundle\Request\ParamFetcherInterface;
Expand All @@ -22,7 +22,7 @@
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Validator\Constraints\IdenticalTo;

class ParamFetcherController extends FOSRestController
class ParamFetcherController extends AbstractFOSRestController
{
/**
* @RequestParam(name="raw", requirements=@IdenticalTo({"foo"="raw", "bar"="foo"}), default="invalid", strict=false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
namespace FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

class RequestBodyParamConverterController extends Controller
class RequestBodyParamConverterController extends AbstractController
{
/**
* @ParamConverter("post", converter="fos_rest.request_body")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
namespace FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller;

use FOS\RestBundle\Controller\Annotations\View;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Validator\Constraints\NotBlank;

/**
* Controller to test serialization of various errors and exceptions.
*
* @author Florian Voutzinos <[email protected]>
*/
class SerializerErrorController extends Controller
class SerializerErrorController extends AbstractController
{
/**
* @View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@

namespace FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller;

use FOS\RestBundle\Controller\AbstractFOSRestController;
use FOS\RestBundle\Controller\Annotations\Get;
use FOS\RestBundle\Controller\Annotations\Version;
use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Component\HttpFoundation\Request;

/**
* @author Ener-Getick <[email protected]>
*
* @Version({"1.2"})
*/
class Version2Controller extends FOSRestController
class Version2Controller extends AbstractFOSRestController
{
/**
* @View("TestBundle:Version:version.html.twig")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

namespace FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller;

use FOS\RestBundle\Controller\AbstractFOSRestController;
use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Component\HttpFoundation\Request;

/**
* @author Ener-Getick <[email protected]>
*/
class VersionController extends FOSRestController
class VersionController extends AbstractFOSRestController
{
/**
* @View("TestBundle:Version:version.html.twig")
Expand Down
11 changes: 8 additions & 3 deletions Tests/Functional/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@ class ConfigurationTest extends WebTestCase
{
public function testDisabledTemplating()
{
$this->createClient(['test_case' => 'Templating']);
$kernel = self::bootKernel(['test_case' => 'Templating']);
$container = $kernel->getContainer();

$this->assertFalse($container->has('fos_rest.templating'));
}

public function testToolbar()
{
$this->createClient(['test_case' => 'Configuration'])
->request(
$client = $this->createClient(['test_case' => 'Configuration']);
$client->request(
'GET',
'/_profiler/empty/search/results?limit=10',
[],
[],
['HTTP_Accept' => 'application/json']
);

$this->assertSame('text/html; charset=UTF-8', $client->getResponse()->headers->get('Content-Type'));
}
}
2 changes: 2 additions & 0 deletions Tests/Functional/ParamFetcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public function testFileParamImageConstraintArrayException()
public function testValidQueryParameter()
{
$this->client->request('POST', '/params?foz=val1');

$this->assertArraySubset(array('foz' => ''), $this->getData());
}

public function testIncompatibleQueryParameter()
Expand Down
Loading

0 comments on commit 5701cb9

Please sign in to comment.