Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 109f392

Browse files
committed
Added RouteMaker (as opposed to GenericMaker)
1 parent 52e329e commit 109f392

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

AutoRoute/RouteMaker/RouteMaker.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ public function __construct(DocumentManager $dm)
2626

2727
public function init(array $options)
2828
{
29-
$this->defaults = $defaults;
29+
$options = array_merge(array(
30+
'defaults' => array(),
31+
), $options);
32+
33+
$this->defaults = $options['defaults'];
3034
}
3135

3236
public function make(RouteStack $routeStack)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\AutoRoute\RouteMaker;
4+
5+
class RouteMakerTest extends GenericMakerTest
6+
{
7+
protected $routeClass = 'Symfony\Cmf\Bundle\RoutingExtraBundle\Document\Route';
8+
protected $makerClass = 'Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\RouteMaker\RouteMaker';
9+
10+
public function testMake()
11+
{
12+
$this->routeMaker->init(array(
13+
'defaults' => array('_controller' => 'foobar')
14+
));
15+
16+
$this->routeStack->expects($this->once())
17+
->method('getFullPaths')
18+
->will($this->returnValue(array(
19+
'test',
20+
'test/foo',
21+
)));
22+
23+
$test = $this;
24+
$this->routeStack->expects($this->exactly(2))
25+
->method('addRoute')
26+
->will($this->returnCallback(function ($doc) use ($test) {
27+
static $i = 0;
28+
$expected = array('/test', '/test/foo');
29+
30+
$this->assertInstanceOf(
31+
'Symfony\Cmf\Bundle\RoutingExtraBundle\Document\Route',
32+
$doc
33+
);
34+
35+
$this->assertEquals($expected[$i++], $doc->getId());
36+
$defaults = $doc->getDefaults();
37+
$this->assertTrue(isset($defaults['_controller']));
38+
$this->assertEquals('foobar', $defaults['_controller']);
39+
}));
40+
41+
$this->routeMaker->make($this->routeStack);
42+
}
43+
}

0 commit comments

Comments
 (0)