Skip to content

Commit

Permalink
[zendframework#3625] Added additional test for short names
Browse files Browse the repository at this point in the history
- Added test demonstrating routes may be pulled by short names. Ran this
  test both before and after the setInvokableClass() change; passed in
  both cases.
  • Loading branch information
weierophinney committed Feb 1, 2013
1 parent 5af3c12 commit 4ca56a3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/ZendTest/Mvc/Router/RoutePluginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,36 @@ public function testDoesNotInvokeDiForShippedRoutes($routeName, $options)
$this->fail(implode("\n\n", $messages));
}
}

/**
* @dataProvider shippedRoutes
*/
public function testDoesNotInvokeDiForShippedRoutesUsingShortName($routeName, $options)
{
// Setup route plugin manager
$routes = new RoutePluginManager();
foreach ($this->shippedRoutes() as $name => $info) {
$routes->setInvokableClass($name, $info[0]);
}

// Add DI abstract factory
$di = new Di;
$diAbstractFactory = new DiAbstractServiceFactory($di, DiAbstractServiceFactory::USE_SL_BEFORE_DI);
$routes->addAbstractFactory($diAbstractFactory);

$shortName = substr($routeName, strrpos($routeName, '\\') + 1);

$this->assertTrue($routes->has($shortName));

try {
$route = $routes->get($shortName, $options);
$this->assertInstanceOf($routeName, $route);
} catch (\Exception $e) {
$messages = array();
do {
$messages[] = $e->getMessage() . "\n" . $e->getTraceAsString();
} while ($e = $e->getPrevious());
$this->fail(implode("\n\n", $messages));
}
}
}

0 comments on commit 4ca56a3

Please sign in to comment.