Issue #3358 - Fix for console router not accepting controller word as part of a route #4182

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+15 −1
Split
@@ -797,7 +797,7 @@ public function match(Request $request, $pathOffset = null)
return null; // there are extraneous params that were not consumed
}
- return new RouteMatch(array_merge($this->defaults, $matches));
+ return new RouteMatch(array_replace($matches, $this->defaults));
}
/**
@@ -695,4 +695,18 @@ public function testFactory()
)
);
}
+
+ public function testMatchMergeOfTheDefaults()
+ {
+ $defaults = array(
+ 'controller' => 'Controller/Test',
+ );
+
+ $request = new ConsoleRequest(array('scriptname.php', 'foo', 'controller'));
+ $route = new Simple('foo controller', array(), $defaults);
+ $match = $route->match($request);
+
+ $this->assertInstanceOf('Zend\Mvc\Router\Console\RouteMatch', $match);
+ $this->assertEquals($defaults['controller'], $match->getParam('controller'));
+ }
}