Skip to content

Commit 5dfca90

Browse files
author
Rachel
committed
Add support for Symfony 5, drop support for PHP5, drop support for Symfony 2
1 parent e42ed45 commit 5dfca90

File tree

9 files changed

+30
-40
lines changed

9 files changed

+30
-40
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/vendor/
55
/node_modules/
66
/.phpunit/
7+
/.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ language: php
22

33
matrix:
44
include:
5-
- php: 5.6
65
- php: 7.1
76
- php: 7.2
87
- php: 7.3
9-
- php: 7.1
10-
env: SYMFONY_VERSION='2.8.*'
118
- php: 7.1
129
env: SYMFONY_VERSION='3.4.*'
1310
- php: 7.1

Command/RouterDebugExposedCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
104104
'show_controllers' => $input->getOption('show-controllers'),
105105
));
106106
}
107+
return 0;
107108
}
108109

109110
protected function getRoutes($domain = array())

Tests/Command/DumpCommandTest.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DumpCommandTest extends TestCase
2121
protected $router;
2222
private $serializer;
2323

24-
public function setUp()
24+
public function setUp(): void
2525
{
2626
$this->extractor = $this->getMockBuilder('FOS\JsRoutingBundle\Extractor\ExposedRoutesExtractor')
2727
->disableOriginalConstructor()
@@ -47,8 +47,8 @@ public function testExecute()
4747
$tester = new CommandTester($command);
4848
$tester->execute(array('--target' => '/tmp/dump-command-test'));
4949

50-
$this->assertContains('Dumping exposed routes.', $tester->getDisplay());
51-
$this->assertContains('[file+] /tmp/dump-command-test', $tester->getDisplay());
50+
$this->assertStringContainsString('Dumping exposed routes.', $tester->getDisplay());
51+
$this->assertStringContainsString('[file+] /tmp/dump-command-test', $tester->getDisplay());
5252

5353
$this->assertEquals('fos.Router.setData({"base_url":"","routes":{"literal":{"tokens":[["text","\/homepage"]],"defaults":[],"requirements":[],"hosttokens":[]},"blog":{"tokens":[["variable","\/","[^\/]++","slug"],["text","\/blog-post"]],"defaults":[],"requirements":[],"hosttokens":[["text","localhost"]]}},"prefix":"","host":"","scheme":""});', file_get_contents('/tmp/dump-command-test'));
5454
}
@@ -67,8 +67,8 @@ public function testExecuteCallbackOption()
6767
'--callback' => 'test',
6868
));
6969

70-
$this->assertContains('Dumping exposed routes.', $tester->getDisplay());
71-
$this->assertContains('[file+] /tmp/dump-command-test', $tester->getDisplay());
70+
$this->assertStringContainsString('Dumping exposed routes.', $tester->getDisplay());
71+
$this->assertStringContainsString('[file+] /tmp/dump-command-test', $tester->getDisplay());
7272

7373
$this->assertEquals('test({"base_url":"","routes":{"literal":{"tokens":[["text","\/homepage"]],"defaults":[],"requirements":[],"hosttokens":[]},"blog":{"tokens":[["variable","\/","[^\/]++","slug"],["text","\/blog-post"]],"defaults":[],"requirements":[],"hosttokens":[["text","localhost"]]}},"prefix":"","host":"","scheme":""});', file_get_contents('/tmp/dump-command-test'));
7474
}
@@ -89,30 +89,26 @@ public function testExecuteFormatOption()
8989
'--format' => 'json',
9090
));
9191

92-
$this->assertContains('Dumping exposed routes.', $tester->getDisplay());
93-
$this->assertContains('[file+] /tmp/dump-command-test', $tester->getDisplay());
92+
$this->assertStringContainsString('Dumping exposed routes.', $tester->getDisplay());
93+
$this->assertStringContainsString('[file+] /tmp/dump-command-test', $tester->getDisplay());
9494

9595
$this->assertEquals($json, file_get_contents('/tmp/dump-command-test'));
9696
}
9797

98-
/**
99-
* @expectedException \RuntimeException
100-
* @expectedExceptionMessage Unable to create directory /root/dir/../web/js
101-
*/
10298
public function testExecuteUnableToCreateDirectory()
10399
{
100+
$this->expectException(\RuntimeException::class);
101+
$this->expectExceptionMessage('Unable to create directory /root/dir/../web/js');
104102
$command = new DumpCommand($this->extractor, $this->serializer, '/root/dir');
105103

106104
$tester = new CommandTester($command);
107105
$tester->execute(array());
108106
}
109107

110-
/**
111-
* @expectedException \RuntimeException
112-
* @expectedExceptionMessage Unable to write file /tmp
113-
*/
114108
public function testExecuteUnableToWriteFile()
115109
{
110+
$this->expectException(\RuntimeException::class);
111+
$this->expectExceptionMessage('Unable to write file /tmp');
116112
$this->serializer->expects($this->once())
117113
->method('serialize')
118114
->will($this->returnValue('{"base_url":"","routes":{"literal":{"tokens":[["text","\/homepage"]],"defaults":[],"requirements":[],"hosttokens":[]},"blog":{"tokens":[["variable","\/","[^\/]++","slug"],["text","\/blog-post"]],"defaults":[],"requirements":[],"hosttokens":[["text","localhost"]]}},"prefix":"","host":"","scheme":""}'));

Tests/Command/RouterDebugExposedCommandTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RouterDebugExposedCommandTest extends TestCase
2222
protected $extractor;
2323
protected $router;
2424

25-
public function setUp()
25+
public function setUp(): void
2626
{
2727
$this->extractor = $this->getMockBuilder('FOS\JsRoutingBundle\Extractor\ExposedRoutesExtractor')
2828
->disableOriginalConstructor()
@@ -54,12 +54,10 @@ public function testExecute()
5454
$this->assertRegExp('/list(.*ANY){3}.*\/literal/', $tester->getDisplay());
5555
}
5656

57-
/**
58-
* @expectedException InvalidArgumentException
59-
* @expectedExceptionMessage The route "foobar" does not exist.
60-
*/
6157
public function testExecuteWithNameUnknown()
6258
{
59+
$this->expectException(\InvalidArgumentException::class);
60+
$this->expectExceptionMessage('The route "foobar" does not exist.');
6361
$routes = new RouteCollection();
6462
$routes->add('literal', new Route('/literal'));
6563
$routes->add('blog_post', new Route('/blog-post/{slug}'));
@@ -75,12 +73,10 @@ public function testExecuteWithNameUnknown()
7573
$tester->execute(array('name' => 'foobar'));
7674
}
7775

78-
/**
79-
* @expectedException InvalidArgumentException
80-
* @expectedExceptionMessage The route "literal" was found, but it is not an exposed route.
81-
*/
8276
public function testExecuteWithNameNotExposed()
8377
{
78+
$this->expectException(\InvalidArgumentException::class);
79+
$this->expectExceptionMessage('The route "literal" was found, but it is not an exposed route.');
8480
$routes = new RouteCollection();
8581
$routes->add('literal', new Route('/literal'));
8682
$routes->add('blog_post', new Route('/blog-post/{slug}'));
@@ -116,6 +112,6 @@ public function testExecuteWithName()
116112
$tester = new CommandTester($command);
117113
$tester->execute(array('name' => 'literal'));
118114

119-
$this->assertContains('exposed: true', $tester->getDisplay());
115+
$this->assertStringContainsString('exposed: true', $tester->getDisplay());
120116
}
121117
}

Tests/Controller/ControllerTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use FOS\JsRoutingBundle\Serializer\Normalizer\RoutesResponseNormalizer;
1818
use PHPUnit\Framework\TestCase;
1919
use Symfony\Component\HttpFoundation\Request;
20+
use Symfony\Component\HttpKernel\Exception\HttpException;
2021
use Symfony\Component\Routing\Route;
2122
use Symfony\Component\Routing\RouteCollection;
2223
use Symfony\Component\Serializer\Encoder\JsonEncoder;
@@ -26,12 +27,12 @@ class ControllerTest extends TestCase
2627
{
2728
private $cachePath;
2829

29-
public function setUp()
30+
public function setUp(): void
3031
{
3132
$this->cachePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'fosJsRouting' . DIRECTORY_SEPARATOR . 'data.json';
3233
}
3334

34-
public function tearDown()
35+
public function tearDown(): void
3536
{
3637
unlink($this->cachePath);
3738
}
@@ -108,11 +109,9 @@ public static function dataProviderForTestGenerateWithCallback()
108109
);
109110
}
110111

111-
/**
112-
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
113-
*/
114112
public function testGenerateWithInvalidCallback()
115113
{
114+
$this->expectException(HttpException::class);
116115
$controller = new Controller($this->getSerializer(), $this->getExtractor());
117116
$controller->indexAction($this->getRequest('/', 'GET', array('callback' => '(function xss(x) {evil()})')), 'json');
118117
}

Tests/DependencyInjection/FOSJsRoutingExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class FOSJsRoutingExtensionTest extends TestCase
1919
{
20-
public function setUp()
20+
public function setUp(): void
2121
{
2222
if (!class_exists('Symfony\Component\DependencyInjection\ContainerBuilder')) {
2323
$this->markTestSkipped('The DependencyInjection component is not available.');

Tests/Extractor/ExposedRoutesExtractorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ExposedRoutesExtractorTest extends TestCase
2626
{
2727
private $cacheDir;
2828

29-
public function setUp()
29+
public function setUp(): void
3030
{
3131
if (!class_exists('Symfony\\Component\\Routing\\Route')) {
3232
$this->markTestSkipped('The Routing component is not available.');

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^5.3.9|^7.0",
20-
"symfony/framework-bundle": "~2.7||~3.0|^4.0",
21-
"symfony/serializer": "~2.7||~3.0|^4.0",
22-
"symfony/console": "~2.7||~3.0|^4.0",
19+
"php": "^7.1",
20+
"symfony/framework-bundle": "~3.0|^4.0|^5.0",
21+
"symfony/serializer": "~3.0|^4.0|^5.0",
22+
"symfony/console": "~3.0|^4.0|^5.0",
2323
"willdurand/jsonp-callback-validator": "~1.0"
2424
},
2525
"require-dev": {
26-
"symfony/expression-language": "~2.7||~3.0|^4.0",
26+
"symfony/expression-language": "~3.0|^4.0|^5.0",
2727
"symfony/phpunit-bridge": "^3.3|^4.0"
2828
},
2929
"autoload": {

0 commit comments

Comments
 (0)