public function ChainRouterTest::testGenerate

File

drupal/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ChainRouterTest.php, line 433

Class

ChainRouterTest

Namespace

Symfony\Cmf\Component\Routing\Tests\Routing

Code

public function testGenerate() {
  $url = '/test';
  $name = 'test';
  $parameters = array(
    'test' => 'value',
  );
  list($lower, $low, $high) = $this
    ->createRouterMocks();
  $high
    ->expects($this
    ->once())
    ->method('generate')
    ->with($name, $parameters, false)
    ->will($this
    ->throwException(new \Symfony\Component\Routing\Exception\RouteNotFoundException()));
  $low
    ->expects($this
    ->once())
    ->method('generate')
    ->with($name, $parameters, false)
    ->will($this
    ->returnValue($url));
  $lower
    ->expects($this
    ->never())
    ->method('generate');
  $this->router
    ->add($low, 10);
  $this->router
    ->add($high, 100);
  $result = $this->router
    ->generate($name, $parameters);
  $this
    ->assertEquals($url, $result);
}