Skip to content

Commit 6368557

Browse files
committed
use phpunit 6
1 parent 6245aef commit 6368557

10 files changed

+139
-98
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ env:
3030
global:
3131
- SYMFONY_DEPRECATIONS_HELPER="/.*each.*/"
3232
- SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml"
33-
- SYMFONY_PHPUNIT_VERSION=5.7
33+
- SYMFONY_PHPUNIT_VERSION=6
3434
- TEST_INSTALLATION=false
3535

3636
matrix:

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
Version/Branch | Travis | Coveralls |
1212
------ | ------ | --------- |
13-
2.1.0 | [![Build Status][travis_stable_badge]][travis_link] | [![Coverage Status][coveralls_stable_badge]][coveralls_stable_link] |
1413
master | [![Build Status][travis_unstable_badge]][travis_link] | [![Coverage Status][coveralls_unstable_badge]][coveralls_unstable_link] |
1514

1615
This package is part of the [Symfony Content Management Framework (CMF)](http://cmf.symfony.com/) and licensed
@@ -68,12 +67,9 @@ Thanks to
6867

6968
This package is available under the [MIT license](src/Resources/meta/LICENSE).
7069

71-
[travis_stable_badge]: https://travis-ci.org/symfony-cmf/Routing.svg?branch=2.x
7270
[travis_unstable_badge]: https://travis-ci.org/symfony-cmf/Routing.svg?branch=master
7371

7472
[travis_link]: https://travis-ci.org/symfony-cmf/Routing
7573

76-
[coveralls_stable_badge]: https://coveralls.io/repos/github/symfony-cmf/routing/badge.svg?branch=2.x
77-
[coveralls_stable_link]: https://coveralls.io/github/symfony-cmf/routing?branch=2.x
7874
[coveralls_unstable_badge]: https://coveralls.io/repos/github/symfony-cmf/routing/badge.svg?branch=master
7975
[coveralls_unstable_link]: https://coveralls.io/github/symfony-cmf/routing?branch=master

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"psr/log": "^1.0"
2222
},
2323
"require-dev": {
24-
"symfony/phpunit-bridge": "^4.2",
24+
"symfony/phpunit-bridge": "^4.2.2",
2525
"symfony/dependency-injection": "^2.8 || ^3.3 || ^4.0",
2626
"symfony/config": "^2.8 || ^3.3 || ^4.0",
2727
"symfony/event-dispatcher": "^2.8 || ^3.3 || ^4.0",

tests/Unit/NestedMatcher/NestedMatcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function testProviderNoMatch()
135135

136136
$matcher = new NestedMatcher($this->provider, $this->finalMatcher);
137137

138-
$this->setExpectedException(ResourceNotFoundException::class);
138+
$this->expectException(ResourceNotFoundException::class);
139139
$matcher->matchRequest($request);
140140
}
141141
}

tests/Unit/NestedMatcher/UrlMatcherTest.php

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Cmf\Component\Routing\Tests\Unit\NestedMatcher;
1313

14+
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Cmf\Component\Routing\NestedMatcher\UrlMatcher;
1617
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
@@ -23,17 +24,35 @@
2324

2425
class UrlMatcherTest extends TestCase
2526
{
26-
protected $routeDocument;
27-
28-
protected $routeCompiled;
29-
30-
protected $matcher;
31-
32-
protected $context;
33-
34-
protected $request;
35-
36-
protected $url = '/foo/bar';
27+
/**
28+
* @var RouteMock|MockObject
29+
*/
30+
private $routeDocument;
31+
32+
/**
33+
* @var CompiledRoute|MockObject
34+
*/
35+
private $routeCompiled;
36+
37+
/**
38+
* @var UrlMatcher
39+
*/
40+
private $matcher;
41+
42+
/**
43+
* @var RequestContext|MockObject
44+
*/
45+
private $context;
46+
47+
/**
48+
* @var Request
49+
*/
50+
private $request;
51+
52+
/**
53+
* @var string
54+
*/
55+
private $url = '/foo/bar';
3756

3857
public function setUp()
3958
{

tests/Unit/Routing/ChainRouterTest.php

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Cmf\Component\Routing\Tests\Routing;
1313

14+
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516
use Psr\Log\LoggerInterface;
1617
use Symfony\Cmf\Component\Routing\ChainRouter;
@@ -35,7 +36,7 @@ class ChainRouterTest extends TestCase
3536
private $router;
3637

3738
/**
38-
* @var RequestContext|\PHPUnit_Framework_MockObject_MockObject
39+
* @var RequestContext|MockObject
3940
*/
4041
private $context;
4142

@@ -84,7 +85,7 @@ public function testSortRouters()
8485
{
8586
list($low, $medium, $high) = $this->createRouterMocks();
8687
// We're using a mock here and not $this->router because we need to ensure that the sorting operation is done only once.
87-
/** @var $router ChainRouter|\PHPUnit_Framework_MockObject_MockObject */
88+
/** @var $router ChainRouter|MockObject */
8889
$router = $this->getMockBuilder(ChainRouter::class)
8990
->disableOriginalConstructor()
9091
->setMethods(['sortRouters'])
@@ -121,7 +122,7 @@ public function testReSortRouters()
121122
list($low, $medium, $high) = $this->createRouterMocks();
122123
$highest = clone $high;
123124
// We're using a mock here and not $this->router because we need to ensure that the sorting operation is done only once.
124-
/** @var $router ChainRouter|\PHPUnit_Framework_MockObject_MockObject */
125+
/** @var $router ChainRouter|MockObject */
125126
$router = $this->getMockBuilder(ChainRouter::class)
126127
->disableOriginalConstructor()
127128
->setMethods(['sortRouters'])
@@ -302,7 +303,7 @@ public function testMatchWithRequestMatchers()
302303
->with($this->callback(function (Request $r) use ($url) {
303304
return $r->getPathInfo() === $url;
304305
}))
305-
->will($this->throwException(new \Symfony\Component\Routing\Exception\ResourceNotFoundException()))
306+
->will($this->throwException(new ResourceNotFoundException()))
306307
;
307308
$low
308309
->expects($this->once())
@@ -413,7 +414,7 @@ public function testMatchRequestAndNotAllowed()
413414
->expects($this->once())
414415
->method('match')
415416
->with($url)
416-
->will($this->throwException(new \Symfony\Component\Routing\Exception\MethodNotAllowedException([])))
417+
->will($this->throwException(new MethodNotAllowedException([])))
417418
;
418419
$low
419420
->expects($this->once())
@@ -428,9 +429,6 @@ public function testMatchRequestAndNotAllowed()
428429
$this->assertEquals(['test'], $result);
429430
}
430431

431-
/**
432-
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
433-
*/
434432
public function testMatchNotFound()
435433
{
436434
$url = '/test';
@@ -451,12 +449,10 @@ public function testMatchNotFound()
451449
$this->router->add($low, 10);
452450
$this->router->add($high, 100);
453451

452+
$this->expectException(ResourceNotFoundException::class);
454453
$this->router->match('/test');
455454
}
456455

457-
/**
458-
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
459-
*/
460456
public function testMatchRequestNotFound()
461457
{
462458
$url = '/test';
@@ -477,14 +473,12 @@ public function testMatchRequestNotFound()
477473
$this->router->add($low, 10);
478474
$this->router->add($high, 100);
479475

476+
$this->expectException(ResourceNotFoundException::class);
480477
$this->router->matchRequest(Request::create('/test'));
481478
}
482479

483480
/**
484481
* Call match on ChainRouter that has RequestMatcher in the chain.
485-
*
486-
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
487-
* @expectedExceptionMessage None of the routers in the chain matched url '/test'
488482
*/
489483
public function testMatchWithRequestMatchersNotFound()
490484
{
@@ -502,13 +496,13 @@ public function testMatchWithRequestMatchersNotFound()
502496

503497
$this->router->add($high, 20);
504498

499+
$this->expectException(ResourceNotFoundException::class);
500+
$this->expectExceptionMessage('None of the routers in the chain matched url \'/test\'');
505501
$this->router->match($url);
506502
}
507503

508504
/**
509505
* If any of the routers throws a not allowed exception and no other matches, we need to see this.
510-
*
511-
* @expectedException \Symfony\Component\Routing\Exception\MethodNotAllowedException
512506
*/
513507
public function testMatchMethodNotAllowed()
514508
{
@@ -530,13 +524,12 @@ public function testMatchMethodNotAllowed()
530524
$this->router->add($low, 10);
531525
$this->router->add($high, 100);
532526

527+
$this->expectException(MethodNotAllowedException::class);
533528
$this->router->match('/test');
534529
}
535530

536531
/**
537532
* If any of the routers throws a not allowed exception and no other matches, we need to see this.
538-
*
539-
* @expectedException \Symfony\Component\Routing\Exception\MethodNotAllowedException
540533
*/
541534
public function testMatchRequestMethodNotAllowed()
542535
{
@@ -558,6 +551,7 @@ public function testMatchRequestMethodNotAllowed()
558551
$this->router->add($low, 10);
559552
$this->router->add($high, 100);
560553

554+
$this->expectException(MethodNotAllowedException::class);
561555
$this->router->matchRequest(Request::create('/test'));
562556
}
563557

@@ -592,9 +586,6 @@ public function testGenerate()
592586
$this->assertEquals($url, $result);
593587
}
594588

595-
/**
596-
* @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
597-
*/
598589
public function testGenerateNotFound()
599590
{
600591
$name = 'test';
@@ -615,13 +606,12 @@ public function testGenerateNotFound()
615606
$this->router->add($low, 10);
616607
$this->router->add($high, 100);
617608

609+
$this->expectException(RouteNotFoundException::class);
618610
$this->router->generate($name, $parameters);
619611
}
620612

621613
/**
622614
* Route is an object but no versatile generator around to do the debug message.
623-
*
624-
* @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
625615
*/
626616
public function testGenerateObjectNotFound()
627617
{
@@ -637,13 +627,12 @@ public function testGenerateObjectNotFound()
637627

638628
$this->router->add($defaultRouter, 200);
639629

630+
$this->expectException(RouteNotFoundException::class);
640631
$this->router->generate($name, $parameters);
641632
}
642633

643634
/**
644635
* A versatile router will generate the debug message.
645-
*
646-
* @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
647636
*/
648637
public function testGenerateObjectNotFoundVersatile()
649638
{
@@ -669,6 +658,7 @@ public function testGenerateObjectNotFoundVersatile()
669658

670659
$this->router->add($chainedRouter, 10);
671660

661+
$this->expectException(RouteNotFoundException::class);
672662
$this->router->generate($name, $parameters);
673663
}
674664

@@ -754,9 +744,6 @@ public function testRouteCollection()
754744
$this->assertEquals(['high', 'low'], $names);
755745
}
756746

757-
/**
758-
* @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
759-
*/
760747
public function testSupport()
761748
{
762749
$router = $this->createMock(VersatileRouter::class);
@@ -774,11 +761,12 @@ public function testSupport()
774761

775762
$this->router->add($router);
776763

764+
$this->expectException(RouteNotFoundException::class);
777765
$this->router->generate('foobar');
778766
}
779767

780768
/**
781-
* @return RouterInterface[]|\PHPUnit_Framework_MockObject_MockObject[]
769+
* @return RouterInterface[]|MockObject[]
782770
*/
783771
protected function createRouterMocks()
784772
{

0 commit comments

Comments
 (0)