$collection->
get('bar'
)->
getOptions(), '->addOptions() adds options to all routes and overwrites existing ones'
);
} public function testAddPrefix() { $collection =
new RouteCollection();
$collection->
add('foo',
$foo =
new Route('/foo'
));
$collection2 =
new RouteCollection();
$collection2->
add('bar',
$bar =
new Route('/bar'
));
$collection->
addCollection($collection2);
$collection->
addPrefix(' / '
);
$this->
assertSame('/foo',
$collection->
get('foo'
)->
getPath(), '->addPrefix() trims the prefix and a single slash has no effect'
);
$collection->
addPrefix('/{admin}',
['admin' => 'admin'
],
['admin' => '\d+'
]);
$this->
assertEquals('/{admin}/foo',
$collection->
get('foo'
)->
getPath(), '->addPrefix() adds a prefix to all routes'
);
$this->
assertEquals('/{admin}/bar',
$collection->
get('bar'
)->
getPath(), '->addPrefix() adds a prefix to all routes'
);
$this->
assertEquals(['admin' => 'admin'
],
$collection->
get('foo'
)->
getDefaults(), '->addPrefix() adds defaults to all routes'
);
$this->
assertEquals(['admin' => 'admin'
],
$collection->
get('bar'
)->
getDefaults(), '->addPrefix() adds defaults to all routes'
);
$this->
assertEquals(['admin' => '\d+'
],
$collection->
get('foo'
)->
getRequirements(), '->addPrefix() adds requirements to all routes'
);
$this->
assertEquals(['admin' => '\d+'
],
$collection->
get('bar'
)->
getRequirements(), '->addPrefix() adds requirements to all routes'
);
$collection->
addPrefix('0'
);
$this->
assertEquals('/0/{admin}/foo',
$collection->
get('foo'
)->
getPath(), '->addPrefix() ensures a prefix must start with a slash and must not end with a slash'
);
$collection->
addPrefix('/ /'
);