Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Add unit tests for chain route generation in tree route stack
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD committed Apr 28, 2013
1 parent 638ec68 commit 5ccd013
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Mvc/Router/Http/TreeRouteStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected function routeFromArray($specs)
throw new Exception\InvalidArgumentException('Chain routes must be an array or Traversable object');
}

$chainRoutes = array($specs) + $specs['chain_routes'];
$chainRoutes = array_merge(array($specs), $specs['chain_routes']);
unset($chainRoutes[0]['chain_routes']);

$options = array(
Expand Down
33 changes: 33 additions & 0 deletions tests/ZendTest/Mvc/Router/Http/TreeRouteStackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,39 @@ public function testPriorityIsPassedToPartRoute()
$this->assertEquals(1000, $routes->get('foo')->priority);
}

public function testPrototypeRoute()
{
$stack = new TreeRouteStack();
$stack->addPrototype(
'bar',
array('type' => 'literal', 'options' => array('route' => '/bar'))
);
$stack->addRoute('foo', 'bar');
$this->assertEquals('/bar', $stack->assemble(array(), array('name' => 'foo')));
}

public function testChainRouteAssembling()
{
$stack = new TreeRouteStack();
$stack->addPrototype(
'bar',
array('type' => 'literal', 'options' => array('route' => '/bar'))
);
$stack->addRoute(
'foo',
array(
'type' => 'literal',
'options' => array(
'route' => '/foo'
),
'chain_routes' => array(
'bar'
),
)
);
$this->assertEquals('/foo/bar', $stack->assemble(array(), array('name' => 'foo')));
}

public function testFactory()
{
$tester = new FactoryTester($this);
Expand Down

0 comments on commit 5ccd013

Please sign in to comment.