浏览代码

[Console] fixed new ArgvInput method

Kris Wallsmith 14 年之前
父节点
当前提交
36ff9abe67

+ 1 - 1
src/Symfony/Component/Console/Input/ArgvInput.php

@@ -276,7 +276,7 @@ class ArgvInput extends Input
                     if (false !== $pos = strpos($token, '=')) {
                         return substr($token, $pos + 1);
                     } else {
-                        return array_shift($this->tokens);
+                        return array_shift($tokens);
                     }
                 }
             }

+ 19 - 0
tests/Symfony/Tests/Component/Console/Input/ArgvInputTest.php

@@ -157,6 +157,25 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
         $input = new TestInput(array('cli.php', 'foo'));
         $this->assertFalse($input->hasParameterOption('--foo'), '->hasParameterOption() returns false if the given short option is not in the raw input');
     }
+
+    /**
+     * @dataProvider provideGetParameterOptionValues
+     */
+    public function testGetParameterOptionEqualSign($argv, $key, $expected)
+    {
+        $input = new ArgvInput($argv);
+        $this->assertEquals($expected, $input->getParameterOption($key), '->getParameterOption() returns the expected value');
+    }
+
+    public function provideGetParameterOptionValues()
+    {
+        return array(
+            array(array('app/console', 'foo:bar', '-e', 'dev'), '-e', 'dev'),
+            array(array('app/console', 'foo:bar', '--env=dev'), '--env', 'dev'),
+            array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), 'dev'),
+            array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), 'dev'),
+        );
+    }
 }
 
 class TestInput extends ArgvInput