Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d9d1501

Browse files
committed
Merge pull request symfony#14 from nacmartin/emptystring
when the route parameter is set but is the empty string, do not take it (workaround for an issue with phpcr-odm)
2 parents ab6aacf + 64bb465 commit d9d1501

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

Routing/DoctrineRouter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function getContext()
144144
*/
145145
public function generate($name, $parameters = array(), $absolute = false)
146146
{
147-
if (isset($parameters['route'])) {
147+
if (isset($parameters['route']) && $parameters['route'] !== '') {
148148
$route = $parameters['route'];
149149
} else {
150150
$route = $this->getRouteFromContent($parameters);

Tests/Routing/DoctrineRouterTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,34 @@ public function testGenerateHome()
102102
$this->assertEquals('/base/', $url);
103103
}
104104

105+
public function testGenerateEmptyRouteString()
106+
{
107+
$this->container->expects($this->once())
108+
->method('get')
109+
->with('request')
110+
->will($this->returnValue($this->request)
111+
);
112+
113+
$this->container->expects($this->any())
114+
->method('get')
115+
->with('request')
116+
->will($this->returnValue($this->request)
117+
);
118+
119+
$this->contentDocument->expects($this->once())
120+
->method('getRoutes')
121+
->will($this->returnValue(array(new RouteMock('/idprefix'))));
122+
123+
$context = $this->buildMock('Symfony\\Component\\Routing\\RequestContext');
124+
$context->expects($this->once())
125+
->method('getBaseUrl')
126+
->will($this->returnValue('/base'));
127+
$this->router->setContext($context);
128+
129+
$url = $this->router->generate('ignore', array('content'=>$this->contentDocument, 'route' => ''));
130+
$this->assertEquals('/base/', $url);
131+
}
132+
105133
public function testGenerateAbsolute()
106134
{
107135
$this->container->expects($this->once())

0 commit comments

Comments
 (0)