public function ChainRouterTest::testReSortRouters in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony-cmf/routing/Tests/Routing/ChainRouterTest.php \Symfony\Cmf\Component\Routing\Tests\Routing\ChainRouterTest::testReSortRouters()
This test ensures that if a router is being added on the fly, the sorting is reset.
@covers \Symfony\Cmf\Component\Routing\ChainRouter::sortRouters @covers \Symfony\Cmf\Component\Routing\ChainRouter::all @covers \Symfony\Cmf\Component\Routing\ChainRouter::add
File
- vendor/
symfony-cmf/ routing/ Tests/ Routing/ ChainRouterTest.php, line 100
Class
Namespace
Symfony\Cmf\Component\Routing\Tests\RoutingCode
public function testReSortRouters() {
list($low, $medium, $high) = $this
->createRouterMocks();
$highest = clone $high;
// We're using a mock here and not $this->router because we need to ensure that the sorting operation is done only once.
/** @var $router ChainRouter|\PHPUnit_Framework_MockObject_MockObject */
$router = $this
->buildMock('Symfony\\Cmf\\Component\\Routing\\ChainRouter', array(
'sortRouters',
));
$router
->expects($this
->at(0))
->method('sortRouters')
->will($this
->returnValue(array(
$high,
$medium,
$low,
)));
// The second time sortRouters() is called, we're supposed to get the newly added router ($highest)
$router
->expects($this
->at(1))
->method('sortRouters')
->will($this
->returnValue(array(
$highest,
$high,
$medium,
$low,
)));
$router
->add($low, 10);
$router
->add($medium, 50);
$router
->add($high, 100);
$this
->assertSame(array(
$high,
$medium,
$low,
), $router
->all());
// Now adding another router on the fly, sorting must have been reset
$router
->add($highest, 101);
$this
->assertSame(array(
$highest,
$high,
$medium,
$low,
), $router
->all());
}