Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed console routes when using same name for group and parameter #4262

Closed
wants to merge 2 commits into from

3 participants

@robertboloc

When using console routes with groups where the name of the group matched a parameter name, like:

'route'    => 'test [-t|--test]:test'

the obtained parameters were incorrect.

@robertboloc robertboloc referenced this pull request in zendframework/ZFTool
Merged

Feature/diagnostics #30

@Thinkscape

You're right!
Apparently I was mistaken and for some reason it worked for me, but now after more testing I confirm this is a bug. Give me some time to check your PR...

@Thinkscape

Looks clear, however please add the following test routes just to be sure:

group (-t | --test ):test
group [-x|-y|-z]:test
group [--foo|--bar|--baz]:test
group (--foo|--bar|--baz):test
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/4262'
Close #4262
d2a555b
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/4262' into develop
Forward port #4262
beeac0b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 18, 2013
  1. @robertboloc
Commits on Apr 19, 2013
  1. @robertboloc

    Added more test routes

    robertboloc authored
This page is out of date. Refresh to see the latest.
View
8 library/Zend/Mvc/Router/Console/Simple.php
@@ -692,17 +692,17 @@ public function match(Request $request, $pathOffset = null)
if (isset($part['alternatives'])) {
if ($part['hasValue']) {
foreach ($part['alternatives'] as $alt) {
- if ($alt == $matchedName) {
+ if ($alt === $matchedName && !isset($matches[$alt])) {
$matches[$alt] = $value;
- } else {
+ } elseif (!isset($matches[$alt])) {
$matches[$alt] = null;
}
}
} else {
foreach ($part['alternatives'] as $alt) {
- if ($alt == $matchedName) {
+ if ($alt === $matchedName && !isset($matches[$alt])) {
$matches[$alt] = true;
- } else {
+ } elseif (!isset($matches[$alt])) {
$matches[$alt] = false;
}
}
View
77 tests/ZendTest/Mvc/Router/Console/SimpleTest.php
@@ -592,6 +592,83 @@ public static function routeProvider()
'baz' => true
)
),
+ // group with group name diferent than options (short)
+ 'group-1' => array(
+ 'group [-t|--test]:testgroup',
+ array('group', '-t'),
+ array(
+ 'group' => true,
+ 'testgroup' => true,
+ )
+ ),
+ // group with group name diferent than options (long)
+ 'group-2' => array(
+ 'group [-t|--test]:testgroup',
+ array('group', '--test'),
+ array(
+ 'group' => true,
+ 'testgroup' => true,
+ )
+ ),
+ // group with same name as option (short)
+ 'group-3' => array(
+ 'group [-t|--test]:test',
+ array('group', '-t'),
+ array(
+ 'group' => true,
+ 'test' => true,
+ )
+ ),
+ // group with same name as option (long)
+ 'group-4' => array(
+ 'group [-t|--test]:test',
+ array('group', '--test'),
+ array(
+ 'group' => true,
+ 'test' => true,
+ )
+ ),
+ 'group-5' => array(
+ 'group (-t | --test ):test',
+ array('group', '--test'),
+ array(
+ 'group' => true,
+ 'test' => true,
+ ),
+ ),
+ 'group-6' => array(
+ 'group (-t | --test ):test',
+ array('group', '-t'),
+ array(
+ 'group' => true,
+ 'test' => true,
+ ),
+ ),
+ 'group-7' => array(
+ 'group [-x|-y|-z]:test',
+ array('group', '-y'),
+ array(
+ 'group' => true,
+ 'test' => true,
+ ),
+ ),
+ 'group-8' => array(
+ 'group [--foo|--bar|--baz]:test',
+ array('group', '--foo'),
+ array(
+ 'group' => true,
+ 'test' => true,
+ ),
+ ),
+ 'group-9' => array(
+ 'group (--foo|--bar|--baz):test',
+ array('group', '--foo'),
+ array(
+ 'group' => true,
+ 'test' => true,
+ ),
+ ),
+
/*'combined-2' => array(
'--foo --bar',
array('a','b', 'c', '--foo', '--bar'),
Something went wrong with that request. Please try again.