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

Skip to content

Commit 5636e48

Browse files
Test to ensure that getParameterOption / hasParameterOption throws no warnings.
1 parent 242e6fc commit 5636e48

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919

2020
class ArgvInputTest extends TestCase
2121
{
22+
protected $last_error = '';
23+
24+
public function customErrorHandler($errno, $errstr, $errfile, $errline) {
25+
$this->last_error = $errstr . " on line " . $errline . " in file " . $errfile;
26+
}
27+
2228
public function testConstructor()
2329
{
2430
$_SERVER['argv'] = array('cli.php', 'foo');
@@ -337,6 +343,21 @@ public function testHasParameterOptionEdgeCasesAndLimitations()
337343
$this->assertFalse($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
338344
}
339345

346+
public function testNoWarningOnInvalidParameterOption()
347+
{
348+
$input = new ArgvInput(array('cli.php', '-edev'));
349+
350+
// Control.
351+
$this->assertTrue($input->hasParameterOption(['-e', '']));
352+
// No warning is thrown if https://github.com/symfony/symfony/pull/26156 is fixed
353+
$this->assertFalse($input->hasParameterOption(['-m', '']));
354+
355+
// Control.
356+
$this->assertEquals('dev', $input->getParameterOption(['-e', '']));
357+
// No warning is thrown if https://github.com/symfony/symfony/pull/26156 is fixed
358+
$this->assertEquals('', $input->getParameterOption(['-m', '']));
359+
}
360+
340361
public function testToString()
341362
{
342363
$input = new ArgvInput(array('cli.php', '-f', 'foo'));

0 commit comments

Comments
 (0)