Skip to content

Commit 1f0d91c

Browse files
committed
Fix tests
1 parent 2723fc7 commit 1f0d91c

File tree

8 files changed

+58
-28
lines changed

8 files changed

+58
-28
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/phpunit.xml
22
/composer.lock
33
/composer.phar
4-
/vendor/
4+
/vendor/
5+
/.phpunit/

.travis.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,37 @@ language: php
22

33
php:
44
- 5.3
5-
- 5.4
6-
- 5.5
75
- 5.6
8-
- hhvm
6+
- 7.0
7+
- 7.1
98

109
matrix:
1110
include:
1211
- php: 5.6
13-
env: SYMFONY_VERSION='2.3.*'
14-
- php: 5.6
15-
env: SYMFONY_VERSION='2.5.*'
16-
- php: 5.6
17-
env: SYMFONY_VERSION='3.0.*'
12+
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak
13+
- php: 7.1
14+
env: SYMFONY_VERSION='2.8.*'
15+
- php: 7.1
16+
env: SYMFONY_VERSION='3.3.*'
17+
- php: hhvm
18+
dist: trusty
1819

1920
sudo: false
2021

2122
cache:
2223
directory:
23-
- $HOME/.composer/cache
24+
- .phpunit
25+
- $HOME/.composer/cache/files
2426

2527
before_install:
26-
- sh -c 'if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/symfony=$SYMFONY_VERSION; fi;'
28+
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi
29+
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update symfony/symfony=$SYMFONY_VERSION; fi
2730

2831
install:
29-
- composer install
32+
- composer update $COMPOSER_FLAGS --prefer-dist
3033

3134
script:
32-
- phpunit --coverage-text
35+
- ./phpunit
3336
- phantomjs Resources/js/run_jsunit.js Resources/js/router_test.html
3437

3538
notifications:

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ Before running the test suite, execute the following Composer command to install
3535
the dependencies used by the bundle:
3636

3737
```bash
38-
$ composer install --dev
38+
$ composer update
3939
```
4040

4141
Then, execute the tests executing:
4242

4343
```bash
44-
$ phpunit
44+
$ ./phpunit
4545
```
4646

4747
### JavaScript Test Suite

Tests/Controller/ControllerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
use FOS\JsRoutingBundle\Controller\Controller;
66
use FOS\JsRoutingBundle\Extractor\ExtractedRoute;
7+
use PHPUnit\Framework\TestCase;
78
use Symfony\Component\HttpFoundation\Request;
89
use Symfony\Component\Serializer\Encoder\JsonEncoder;
910
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
1011
use Symfony\Component\Serializer\Serializer;
1112
use Symfony\Component\HttpKernel\Kernel;
1213
use Symfony\Component\HttpFoundation\Session;
1314

14-
class ControllerTest extends \PHPUnit_Framework_TestCase
15+
class ControllerTest extends TestCase
1516
{
1617
private $cachePath;
1718

@@ -129,7 +130,7 @@ public function testCacheControl()
129130

130131
private function getExtractor(array $exposedRoutes = array(), $baseUrl = '')
131132
{
132-
$extractor = $this->getMock('FOS\\JsRoutingBundle\\Extractor\\ExposedRoutesExtractorInterface');
133+
$extractor = $this->getMockBuilder('FOS\\JsRoutingBundle\\Extractor\\ExposedRoutesExtractorInterface')->getMock();
133134
$extractor
134135
->expects($this->any())
135136
->method('getRoutes')
@@ -179,7 +180,7 @@ private function getRequest($uri, $method = 'GET', $parameters = array(), $cooki
179180

180181
if (version_compare(strtolower(Kernel::VERSION), '2.1.0-dev', '<')) {
181182
$request->setSession(new Session(
182-
$this->getMock('Symfony\Component\HttpFoundation\SessionStorage\SessionStorageInterface')
183+
$this->getMockBuilder('Symfony\Component\HttpFoundation\SessionStorage\SessionStorageInterface')->getMock()
183184
));
184185
}
185186

Tests/DependencyInjection/FOSJsRoutingExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
namespace FOS\JsRoutingBundle\Tests\DependencyInjection;
44

55
use FOS\JsRoutingBundle\DependencyInjection\FOSJsRoutingExtension;
6+
use PHPUnit\Framework\TestCase;
67
use Symfony\Component\DependencyInjection\ContainerBuilder;
78

8-
class FOSJsRoutingExtensionTest extends \PHPUnit_Framework_TestCase
9+
class FOSJsRoutingExtensionTest extends TestCase
910
{
1011
public function setUp()
1112
{

Tests/Extractor/ExposedRoutesExtractorTest.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use FOS\JsRoutingBundle\Extractor\ExposedRoutesExtractor;
1515
use FOS\JsRoutingBundle\Extractor\ExtractedRoute;
16+
use PHPUnit\Framework\TestCase;
1617
use Symfony\Component\Routing\RequestContext;
1718
use Symfony\Component\Routing\Route;
1819
use Symfony\Component\HttpKernel\Kernel;
@@ -22,7 +23,7 @@
2223
*
2324
* @author William DURAND <[email protected]>
2425
*/
25-
class ExposedRoutesExtractorTest extends \PHPUnit_Framework_TestCase
26+
class ExposedRoutesExtractorTest extends TestCase
2627
{
2728
private $cacheDir;
2829

@@ -100,7 +101,9 @@ public function testGetRoutesWithPatterns()
100101

101102
public function testGetCachePath()
102103
{
103-
$router = $this->getMock('Symfony\\Component\\Routing\\Router', array(), array(), '', false);
104+
$router = $this->getMockBuilder('Symfony\\Component\\Routing\\Router')
105+
->disableOriginalConstructor()
106+
->getMock();
104107

105108
$extractor = new ExposedRoutesExtractor($router, array(), $this->cacheDir, array());
106109
$this->assertEquals($this->cacheDir . DIRECTORY_SEPARATOR . 'fosJsRouting' . DIRECTORY_SEPARATOR . 'data.json', $extractor->getCachePath(''));
@@ -113,7 +116,9 @@ public function testGetHostOverHttp($host, $httpPort, $expected)
113116
{
114117
$requestContext = new RequestContext('/app_dev.php', 'GET', $host, 'http', $httpPort);
115118

116-
$router = $this->getMock('Symfony\\Component\\Routing\\Router', array(), array(), '', false);
119+
$router = $this->getMockBuilder('Symfony\\Component\\Routing\\Router')
120+
->disableOriginalConstructor()
121+
->getMock();
117122
$router->expects($this->atLeastOnce())
118123
->method('getContext')
119124
->will($this->returnValue($requestContext));
@@ -137,7 +142,9 @@ public function testGetHostOverHttps($host, $httpsPort, $expected)
137142
{
138143
$requestContext = new RequestContext('/app_dev.php', 'GET', $host, 'https', 80, $httpsPort);
139144

140-
$router = $this->getMock('Symfony\\Component\\Routing\\Router', array(), array(), '', false);
145+
$router = $this->getMockBuilder('Symfony\\Component\\Routing\\Router')
146+
->disableOriginalConstructor()
147+
->getMock();
141148
$router->expects($this->atLeastOnce())
142149
->method('getContext')
143150
->will($this->returnValue($requestContext));
@@ -160,13 +167,17 @@ public function provideTestGetHostOverHttps()
160167
*/
161168
private function getRouter(array $routes)
162169
{
163-
$routeCollection = $this->getMock('Symfony\\Component\\Routing\\RouteCollection', array(), array(), '', false);
170+
$routeCollection = $this->getMockBuilder('Symfony\\Component\\Routing\\RouteCollection')
171+
->disableOriginalConstructor()
172+
->getMock();
164173
$routeCollection
165174
->expects($this->atLeastOnce())
166175
->method('all')
167176
->will($this->returnValue($routes));
168177

169-
$router = $this->getMock('Symfony\\Component\\Routing\\Router', array(), array(), '', false);
178+
$router = $this->getMockBuilder('Symfony\\Component\\Routing\\Router')
179+
->disableOriginalConstructor()
180+
->getMock();
170181
$router
171182
->expects($this->atLeastOnce())
172183
->method('getRouteCollection')

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
"willdurand/jsonp-callback-validator": "~1.0"
2424
},
2525
"require-dev": {
26-
"symfony/expression-language": "~2.4|3.*"
26+
"symfony/expression-language": "~2.4|3.*",
27+
"symfony/phpunit-bridge": "^3.3"
2728
},
28-
"minimum-stability": "dev",
29-
"prefer-stable": true,
3029
"autoload": {
3130
"psr-4": { "FOS\\JsRoutingBundle\\": "" }
3231
},

phpunit

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
// Cache-Id: https://github.com/symfony/phpunit-bridge/commit/29fa7b8196870591f35e1554dd69def482e01fb2
5+
6+
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
7+
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
8+
exit(1);
9+
}
10+
if (\PHP_VERSION_ID >= 70000 && !getenv('SYMFONY_PHPUNIT_VERSION')) {
11+
putenv('SYMFONY_PHPUNIT_VERSION=6.0');
12+
}
13+
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
14+
require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';

0 commit comments

Comments
 (0)