Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / console / Tests / Input / ArrayInputTest.php
index 06e65f7398bdcbfc686c88779bd4546681624609..a3e938acd38febe428bdacb8ac56dd5dac96f806 100644 (file)
@@ -37,15 +37,24 @@ class ArrayInputTest extends TestCase
 
         $input = new ArrayInput(array('--foo'));
         $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters');
+
+        $input = new ArrayInput(array('--foo', '--', '--bar'));
+        $this->assertTrue($input->hasParameterOption('--bar'), '->hasParameterOption() returns true if an option is present in the passed parameters');
+        $this->assertFalse($input->hasParameterOption('--bar', true), '->hasParameterOption() returns false if an option is present in the passed parameters after an end of options signal');
     }
 
     public function testGetParameterOption()
     {
         $input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
         $this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
+        $this->assertFalse($input->getParameterOption('--bar'), '->getParameterOption() returns the default if an option is not present in the passed parameters');
 
         $input = new ArrayInput(array('Fabien', '--foo' => 'bar'));
         $this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
+
+        $input = new ArrayInput(array('--foo', '--', '--bar' => 'woop'));
+        $this->assertEquals('woop', $input->getParameterOption('--bar'), '->getParameterOption() returns the correct value if an option is present in the passed parameters');
+        $this->assertFalse($input->getParameterOption('--bar', false, true), '->getParameterOption() returns false if an option is present in the passed parameters after an end of options signal');
     }
 
     public function testParseArguments()
@@ -92,6 +101,18 @@ class ArrayInputTest extends TestCase
                 array('foo' => 'bar'),
                 '->parse() parses short options',
             ),
+            array(
+                array('--' => null, '-f' => 'bar'),
+                array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')),
+                array('foo' => 'default'),
+                '->parse() does not parse opts after an end of options signal',
+            ),
+            array(
+                array('--' => null),
+                array(),
+                array(),
+                '->parse() does not choke on end of options signal',
+            ),
         );
     }