Skip to content

Commit 30c08e7

Browse files
authored
Merge pull request #285 from FriendsOfSymfony/tests
Fix tests
2 parents 2723fc7 + f3c71a4 commit 30c08e7

File tree

9 files changed

+68
-38
lines changed

9 files changed

+68
-38
lines changed

.gitignore

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

.travis.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
language: php
22

3-
php:
4-
- 5.3
5-
- 5.4
6-
- 5.5
7-
- 5.6
8-
- hhvm
9-
103
matrix:
114
include:
12-
- 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.*'
5+
- php: 5.3
6+
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak
7+
- php: 7.1
8+
- php: 7.1
9+
env: SYMFONY_VERSION='2.8.*'
1810

1911
sudo: false
2012

2113
cache:
2214
directory:
23-
- $HOME/.composer/cache
15+
- .phpunit
16+
- $HOME/.composer/cache/files
2417

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

2822
install:
29-
- composer install
23+
- composer update $COMPOSER_FLAGS --prefer-dist
24+
- npm install google-closure-library
3025

3126
script:
32-
- phpunit --coverage-text
27+
- ./phpunit
3328
- phantomjs Resources/js/run_jsunit.js Resources/js/router_test.html
3429

3530
notifications:

CONTRIBUTING.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,25 @@ 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
4848

49-
First, install [PhantomJS](http://phantomjs.org/) and then, execute this command:
49+
First, install [PhantomJS](http://phantomjs.org/) and [Google Closure
50+
Library](https://github.com/google/closure-library):
51+
52+
```bash
53+
$ npm install google-closure-library
54+
```
55+
56+
Run the JS test suite with:
5057

5158
```bash
5259
$ phantomjs Resources/js/run_jsunit.js Resources/js/router_test.html

Resources/js/router_test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>Router Test</title>
66
</head>
77
<body>
8-
<script language="javascript" type="text/javascript" src="https://rawgit.com/google/closure-library/master/closure/goog/base.js"></script>
8+
<script language="javascript" type="text/javascript" src="../../node_modules/google-closure-library/closure/goog/base.js"></script>
99
<script language="javascript" type="text/javascript" src="router.js"></script>
1010
<script language="javascript" type="text/javascript" src="router.test.js"></script>
1111
</body>

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: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717
],
1818
"require": {
1919
"php": ">=5.3.2",
20-
"symfony/framework-bundle": "~2.0|3.*",
21-
"symfony/serializer": "~2.0|3.*",
22-
"symfony/console": "~2.0|3.*",
20+
"symfony/framework-bundle": "~2.3|3.*",
21+
"symfony/serializer": "~2.3|3.*",
22+
"symfony/console": "~2.3|3.*",
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)