Skip to content

Commit 84c965b

Browse files
acrobatdbu
authored andcommitted
Fixes for symfony 5 support (#448)
* Update dependencies * Add correct return types in tests and cleanup * Fix unit tests * Temporary switch to dev-master * Drop sf 3.4 support * Ingore phpunit cache * Required testing packages * Temporary use fork to test with sf5 support * Switch to main symfony-cmf/testing package
1 parent 5c8cc62 commit 84c965b

29 files changed

+78
-63
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ phpunit.xml
22
composer.lock
33
vendor
44
tests/Fixtures/App/var/
5+
.phpunit.result.cache

.travis.yml

+3-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
language: php
1717

1818
php:
19-
- 7.1
2019
- 7.2
2120
- 7.3
2221

@@ -29,18 +28,14 @@ cache:
2928

3029
env:
3130
global:
32-
- SYMFONY_PHPUNIT_VERSION=6
31+
- SYMFONY_PHPUNIT_VERSION=8
3332
- COMPOSER_MEMORY_LIMIT=-1
3433
- SYMFONY_DEPRECATIONS_HELPER="max[self]=0"
3534

3635
matrix:
3736
include:
38-
- php: 7.1
39-
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_REQUIRE=3.4.* SYMFONY_DEPRECATIONS_HELPER=weak
40-
- php: 7.4
41-
env: SYMFONY_REQUIRE=3.4.*
42-
- php: 7.4
43-
env: SYMFONY_REQUIRE=4.3.*
37+
- php: 7.2
38+
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_REQUIRE=4.4.* SYMFONY_DEPRECATIONS_HELPER=weak
4439
- php: 7.4
4540
env: SYMFONY_REQUIRE=4.4.*
4641
- php: 7.4

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
2.4.0
5+
-----
6+
7+
* Minimum PHP version is now 7.2
8+
* Support Symfony 5. Minimum Symfony version is now 4.4.
9+
* If you generate routes with the CMF route generator, see the CHANGELOG of the routing component as well!
10+
411
2.3.0
512
-----
613

composer.json

+16-10
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,29 @@
1515
}
1616
],
1717
"require": {
18-
"php": "^7.1",
19-
"symfony-cmf/routing": "^2.1.0@dev",
20-
"symfony/framework-bundle": "^3.4 || ^4.3 || ^5.0",
18+
"php": "^7.2",
19+
"symfony-cmf/routing": "dev-master",
20+
"symfony/framework-bundle": "^4.4 || ^5.0",
2121
"twig/twig": "^2.4.4 || ^3.0"
2222
},
2323
"require-dev": {
2424
"jackalope/jackalope-doctrine-dbal": "^1.3",
2525
"doctrine/phpcr-odm": "^1.4|^2.0",
26-
"symfony/phpunit-bridge": "^4.2.2",
27-
"matthiasnoback/symfony-dependency-injection-test": "^2.3.1 | ^4.1.0",
28-
"matthiasnoback/symfony-config-test": "^3.1.1 | ^4.1.0",
26+
"symfony/phpunit-bridge": "^5.0",
27+
"matthiasnoback/symfony-dependency-injection-test": "^4.1.0",
28+
"matthiasnoback/symfony-config-test": "^4.1.0",
2929
"doctrine/orm": "^2.5",
30-
"symfony-cmf/testing": "^3@dev",
30+
"symfony-cmf/testing": "dev-master",
3131
"doctrine/data-fixtures": "^1.0.0",
32-
"symfony/form": "^3.4 || ^4.3 || ^5.0",
33-
"symfony/translation": "^3.4 || ^4.3 || ^5.0",
34-
"symfony/validator": "^3.4 || ^4.3 || ^5.0"
32+
"symfony/form": "^4.4 || ^5.0",
33+
"symfony/translation": "^4.4 || ^5.0",
34+
"symfony/validator": "^4.4 || ^5.0",
35+
"symfony/security-bundle": "^4.4 || ^5.0",
36+
"doctrine/doctrine-bundle": "^2.0",
37+
"symfony/twig-bundle": "^4.4 || ^5.0",
38+
"symfony/monolog-bundle": "^3.5",
39+
"doctrine/phpcr-bundle": "^2.1",
40+
"symfony/serializer": "^4.4 || ^5.0"
3541
},
3642
"suggest": {
3743
"doctrine/phpcr-odm": "To enable support for the PHPCR ODM documents (^1.4)",

tests/Fixtures/App/config/config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
framework:
22
serializer: ~
3-
templating: false

tests/Functional/Controller/RedirectControllerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RedirectControllerTest extends BaseTestCase
2626
*/
2727
protected $controller;
2828

29-
public function setUp()
29+
public function setUp(): void
3030
{
3131
parent::setUp();
3232
$this->db('PHPCR')->createTestNode();

tests/Functional/Doctrine/Orm/RedirectRouteTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RedirectRouteTest extends OrmTestCase
2222

2323
private $controller;
2424

25-
public function setUp()
25+
public function setUp(): void
2626
{
2727
parent::setUp();
2828
$this->clearDb(Route::class);

tests/Functional/Doctrine/Orm/RouteProviderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RouteProviderTest extends OrmTestCase
1818
{
1919
private $repository;
2020

21-
public function setUp()
21+
public function setUp(): void
2222
{
2323
parent::setUp();
2424
$this->clearDb(Route::class);

tests/Functional/Doctrine/Phpcr/RedirectRouteTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RedirectRouteTest extends BaseTestCase
2121
{
2222
const ROUTE_ROOT = '/test/redirectroute';
2323

24-
public function setUp()
24+
public function setUp(): void
2525
{
2626
parent::setUp();
2727
$this->db('PHPCR')->createTestNode();

tests/Functional/Doctrine/Phpcr/RouteProviderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RouteProviderTest extends BaseTestCase
2626
/** @var RouteProvider */
2727
private $repository;
2828

29-
public function setUp()
29+
public function setUp(): void
3030
{
3131
parent::setUp();
3232
$this->db('PHPCR')->createTestNode();

tests/Functional/Doctrine/Phpcr/RouteTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RouteTest extends BaseTestCase
1818
{
1919
const ROUTE_ROOT = '/test/routing';
2020

21-
public function setUp()
21+
public function setUp(): void
2222
{
2323
parent::setUp();
2424
$this->db('PHPCR')->createTestNode();

tests/Functional/Routing/DynamicRouterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DynamicRouterTest extends BaseTestCase
4141

4242
const ROUTE_ROOT = '/test/routing';
4343

44-
public function setUp()
44+
public function setUp(): void
4545
{
4646
parent::setUp();
4747

tests/Unit/DependencyInjection/CmfRoutingExtensionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class CmfRoutingExtensionTest extends AbstractExtensionTestCase
2121
{
22-
protected function getContainerExtensions()
22+
protected function getContainerExtensions(): array
2323
{
2424
return [
2525
new CmfRoutingExtension(),

tests/Unit/DependencyInjection/Compiler/SetRouterPassTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class SetRouterPassTest extends AbstractCompilerPassTestCase
1919
{
20-
protected function registerCompilerPass(ContainerBuilder $container)
20+
protected function registerCompilerPass(ContainerBuilder $container): void
2121
{
2222
$container->addCompilerPass(new SetRouterPass());
2323
}

tests/Unit/DependencyInjection/Compiler/TemplatingValidatorPassTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class TemplatingValidatorPassTest extends AbstractCompilerPassTestCase
2222
{
23-
public function setUp()
23+
public function setUp(): void
2424
{
2525
if (!\class_exists(EngineInterface::class)) {
2626
$this->markTestSkipped();
@@ -31,7 +31,7 @@ public function setUp()
3131
$this->registerValidatorService();
3232
}
3333

34-
protected function registerCompilerPass(ContainerBuilder $container)
34+
protected function registerCompilerPass(ContainerBuilder $container): void
3535
{
3636
$container->addCompilerPass(new TemplatingValidatorPass());
3737
}

tests/Unit/DependencyInjection/Compiler/ValidationPassTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class ValidationPassTest extends AbstractCompilerPassTestCase
1919
{
20-
protected function registerCompilerPass(ContainerBuilder $container)
20+
protected function registerCompilerPass(ContainerBuilder $container): void
2121
{
2222
$container->addCompilerPass(new ValidationPass());
2323
}

tests/Unit/DependencyInjection/ConfigurationTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@
1414
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionConfigurationTestCase;
1515
use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\CmfRoutingExtension;
1616
use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Configuration;
17+
use Symfony\Component\Config\Definition\ConfigurationInterface;
18+
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
1719

1820
class ConfigurationTest extends AbstractExtensionConfigurationTestCase
1921
{
20-
protected function getContainerExtension()
22+
protected function getContainerExtension(): ExtensionInterface
2123
{
2224
return new CmfRoutingExtension();
2325
}
2426

25-
protected function getConfiguration()
27+
protected function getConfiguration(): ConfigurationInterface
2628
{
2729
return new Configuration();
2830
}

tests/Unit/DependencyInjection/XmlSchemaTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class XmlSchemaTest extends XmlSchemaTestCase
1919

2020
protected $schemaPath;
2121

22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
$this->fixturesPath = __DIR__.'/../../Fixtures/fixtures/config/';
2525
$this->schemaPath = __DIR__.'/../../../src/Resources/config/schema/routing-1.0.xsd';

tests/Unit/Doctrine/Orm/ContentRepositoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ContentRepositoryTest extends TestCase
2727

2828
private $objectRepository;
2929

30-
public function setUp()
30+
public function setUp(): void
3131
{
3232
$this->document = new \stdClass();
3333
$this->objectManager = $this->createMock(ObjectManager::class);

tests/Unit/Doctrine/Orm/RouteProviderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class RouteProviderTest extends TestCase
5555
*/
5656
private $candidatesMock;
5757

58-
public function setUp()
58+
public function setUp(): void
5959
{
6060
$this->routeMock = $this->createMock(Route::class);
6161
$this->route2Mock = $this->createMock(Route::class);

tests/Unit/Doctrine/Phpcr/ContentRepositoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ContentRepositoryTest extends TestCase
3030

3131
private $managerRegistry;
3232

33-
public function setUp()
33+
public function setUp(): void
3434
{
3535
$this->document = new \stdClass();
3636
$this->document2 = new \stdClass();

tests/Unit/Doctrine/Phpcr/IdPrefixListenerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class IdPrefixListenerTest extends TestCase
4141
*/
4242
protected $routeMock;
4343

44-
public function setUp()
44+
public function setUp(): void
4545
{
4646
$this->candidatesMock = $this->createMock(PrefixCandidates::class);
4747
$this->candidatesMock

tests/Unit/Doctrine/Phpcr/LocaleListenerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class LocaleListenerTest extends TestCase
4040
*/
4141
protected $routeMock;
4242

43-
public function setUp()
43+
public function setUp(): void
4444
{
4545
$this->candidatesMock = $this->createMock(PrefixCandidates::class);
4646

tests/Unit/Doctrine/Phpcr/RouteProviderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class RouteProviderTest extends TestCase
6060
*/
6161
protected $route2Mock;
6262

63-
public function setUp()
63+
public function setUp(): void
6464
{
6565
$this->routeMock = $this->createMock(Route::class);
6666
$this->route2Mock = $this->createMock(Route::class);

tests/Unit/Doctrine/Phpcr/RouteTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RouteTest extends TestCase
2121

2222
private $childRoute1;
2323

24-
public function setUp()
24+
public function setUp(): void
2525
{
2626
$this->route = new Route();
2727

tests/Unit/Form/Type/RouteTypeTypeTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RouteTypeTypeTest extends TestCase
2222
*/
2323
private $type;
2424

25-
public function setUp()
25+
public function setUp(): void
2626
{
2727
$this->type = new RouteTypeType();
2828
}

tests/Unit/Routing/DynamicRouterTest.php

+23-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2525
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
2626
use Symfony\Component\Routing\RequestContext;
27+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface;
2728

2829
class DynamicRouterTest extends TestCase
2930
{
@@ -62,7 +63,7 @@ class DynamicRouterTest extends TestCase
6263
*/
6364
private $eventDispatcher;
6465

65-
public function setUp()
66+
public function setUp(): void
6667
{
6768
$this->matcher = $this->createMock(UrlMatcherInterface::class);
6869
$this->matcher->expects($this->once())
@@ -95,9 +96,15 @@ private function assertRequestAttributes($request)
9596
*/
9697
public function testMatch()
9798
{
99+
$dispatchParams = [Events::PRE_DYNAMIC_MATCH, $this->equalTo(new RouterMatchEvent())];
100+
if ($this->eventDispatcher instanceof ContractsEventDispatcherInterface) {
101+
// New Symfony 4.3 EventDispatcher signature
102+
$dispatchParams = [$this->equalTo(new RouterMatchEvent()), Events::PRE_DYNAMIC_MATCH];
103+
}
104+
98105
$this->eventDispatcher->expects($this->once())
99106
->method('dispatch')
100-
->with(Events::PRE_DYNAMIC_MATCH, $this->equalTo(new RouterMatchEvent()))
107+
->with(...$dispatchParams)
101108
;
102109

103110
$parameters = $this->router->match('/foo');
@@ -108,9 +115,15 @@ public function testMatch()
108115

109116
public function testMatchRequest()
110117
{
118+
$dispatchParams = [Events::PRE_DYNAMIC_MATCH_REQUEST, $this->equalTo(new RouterMatchEvent($this->request))];
119+
if ($this->eventDispatcher instanceof ContractsEventDispatcherInterface) {
120+
// New Symfony 4.3 EventDispatcher signature
121+
$dispatchParams = [$this->equalTo(new RouterMatchEvent($this->request)), Events::PRE_DYNAMIC_MATCH_REQUEST];
122+
}
123+
111124
$this->eventDispatcher->expects($this->once())
112125
->method('dispatch')
113-
->with(Events::PRE_DYNAMIC_MATCH_REQUEST, $this->equalTo(new RouterMatchEvent($this->request)))
126+
->with(...$dispatchParams)
114127
;
115128

116129
$parameters = $this->router->matchRequest($this->request);
@@ -126,9 +139,15 @@ public function testMatchNoRequest()
126139
{
127140
$this->router->setRequestStack(new RequestStack());
128141

142+
$dispatchParams = [Events::PRE_DYNAMIC_MATCH, $this->equalTo(new RouterMatchEvent())];
143+
if ($this->eventDispatcher instanceof ContractsEventDispatcherInterface) {
144+
// New Symfony 4.3 EventDispatcher signature
145+
$dispatchParams = [$this->equalTo(new RouterMatchEvent()), Events::PRE_DYNAMIC_MATCH];
146+
}
147+
129148
$this->eventDispatcher->expects($this->once())
130149
->method('dispatch')
131-
->with(Events::PRE_DYNAMIC_MATCH, $this->equalTo(new RouterMatchEvent()))
150+
->with(...$dispatchParams)
132151
;
133152

134153
$this->expectException(ResourceNotFoundException::class);

tests/Unit/Validator/Constraints/RouteDefaultsTemplatingValidatorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function mockEngine()
2121
return $this->createMock(EngineInterface::class);
2222
}
2323

24-
protected function setUp()
24+
protected function setUp(): void
2525
{
2626
if (!\class_exists(EngineInterface::class)) {
2727
$this->markTestSkipped();

0 commit comments

Comments
 (0)