/**
  * Adds a route collection to the current set of routes (at the end of the current set).
  *
  * @param RouteCollection $collection A RouteCollection instance
  * @param string          $prefix     An optional prefix to add before each pattern of the route collection
  */
 public function addCollection(RouteCollection $collection, $prefix = '')
 {
     $collection->addPrefix($prefix);
     foreach ($collection->getResources() as $resource) {
         $this->addResource($resource);
     }
     $this->routes = array_merge($this->routes, $collection->getRoutes());
 }
 public function testAddPrefix()
 {
     $collection = new RouteCollection();
     $collection->addRoute('foo', $foo = new Route('/foo'));
     $collection->addRoute('bar', $bar = new Route('/bar'));
     $collection->addPrefix('/admin');
     $this->assertEquals('/admin/foo', $collection->getRoute('foo')->getPattern(), '->addPrefix() adds a prefix to all routes');
     $this->assertEquals('/admin/bar', $collection->getRoute('bar')->getPattern(), '->addPrefix() adds a prefix to all routes');
 }
$collection->addRoute('foo', $foo = new Route('/foo'));
$collection1 = new RouteCollection();
$collection1->addRoute('foo', $foo1 = new Route('/foo1'));
$collection1->addRoute('bar', $bar1 = new Route('/bar1'));
$collection->addCollection($collection1);
$t->is($collection->getRoutes(), array('foo' => $foo1, 'bar' => $bar1), '->addCollection() adds routes from another collection');
$collection = new RouteCollection();
$collection->addRoute('foo', $foo = new Route('/foo'));
$collection1 = new RouteCollection();
$collection1->addRoute('foo', $foo1 = new Route('/foo1'));
$collection->addCollection($collection1, '/foo');
$t->is($collection->getRoute('foo')->getPattern(), '/foo/foo1', '->addCollection() can add a prefix to all merged routes');
$collection = new RouteCollection();
$collection->addResource($foo = new FileResource('foo'));
$collection1 = new RouteCollection();
$collection1->addResource($foo1 = new FileResource('foo1'));
$collection->addCollection($collection1);
$t->is($collection->getResources(), array($foo, $foo1), '->addCollection() merges resources');
// ->addPrefix()
$t->diag('->addPrefix()');
$collection = new RouteCollection();
$collection->addRoute('foo', $foo = new Route('/foo'));
$collection->addRoute('bar', $bar = new Route('/bar'));
$collection->addPrefix('/admin');
$t->is($collection->getRoute('foo')->getPattern(), '/admin/foo', '->addPrefix() adds a prefix to all routes');
$t->is($collection->getRoute('bar')->getPattern(), '/admin/bar', '->addPrefix() adds a prefix to all routes');
// ->getResources() ->addResource()
$t->diag('->getResources() ->addResource()');
$collection = new RouteCollection();
$collection->addResource($foo = new FileResource('foo'));
$t->is($collection->getResources(), array($foo), '->addResources() adds a resource');