updated packages
This commit is contained in:
@@ -21,47 +21,47 @@ class ArrayInputTest extends TestCase
|
||||
{
|
||||
public function testGetFirstArgument()
|
||||
{
|
||||
$input = new ArrayInput(array());
|
||||
$input = new ArrayInput([]);
|
||||
$this->assertNull($input->getFirstArgument(), '->getFirstArgument() returns null if no argument were passed');
|
||||
$input = new ArrayInput(array('name' => 'Fabien'));
|
||||
$input = new ArrayInput(['name' => 'Fabien']);
|
||||
$this->assertEquals('Fabien', $input->getFirstArgument(), '->getFirstArgument() returns the first passed argument');
|
||||
$input = new ArrayInput(array('--foo' => 'bar', 'name' => 'Fabien'));
|
||||
$input = new ArrayInput(['--foo' => 'bar', 'name' => 'Fabien']);
|
||||
$this->assertEquals('Fabien', $input->getFirstArgument(), '->getFirstArgument() returns the first passed argument');
|
||||
}
|
||||
|
||||
public function testHasParameterOption()
|
||||
{
|
||||
$input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
|
||||
$input = new ArrayInput(['name' => 'Fabien', '--foo' => 'bar']);
|
||||
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters');
|
||||
$this->assertFalse($input->hasParameterOption('--bar'), '->hasParameterOption() returns false if an option is not present in the passed parameters');
|
||||
|
||||
$input = new ArrayInput(array('--foo'));
|
||||
$input = new ArrayInput(['--foo']);
|
||||
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters');
|
||||
|
||||
$input = new ArrayInput(array('--foo', '--', '--bar'));
|
||||
$input = new ArrayInput(['--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'));
|
||||
$input = new ArrayInput(['name' => 'Fabien', '--foo' => 'bar']);
|
||||
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
|
||||
$this->assertEquals('default', $input->getParameterOption('--bar', 'default'), '->getParameterOption() returns the default value if an option is not present in the passed parameters');
|
||||
|
||||
$input = new ArrayInput(array('Fabien', '--foo' => 'bar'));
|
||||
$input = new ArrayInput(['Fabien', '--foo' => 'bar']);
|
||||
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
|
||||
|
||||
$input = new ArrayInput(array('--foo', '--', '--bar' => 'woop'));
|
||||
$input = new ArrayInput(['--foo', '--', '--bar' => 'woop']);
|
||||
$this->assertEquals('woop', $input->getParameterOption('--bar'), '->getParameterOption() returns the correct value if an option is present in the passed parameters');
|
||||
$this->assertEquals('default', $input->getParameterOption('--bar', 'default', true), '->getParameterOption() returns the default value if an option is present in the passed parameters after an end of options signal');
|
||||
}
|
||||
|
||||
public function testParseArguments()
|
||||
{
|
||||
$input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'))));
|
||||
$input = new ArrayInput(['name' => 'foo'], new InputDefinition([new InputArgument('name')]));
|
||||
|
||||
$this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() parses required arguments');
|
||||
$this->assertEquals(['name' => 'foo'], $input->getArguments(), '->parse() parses required arguments');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,50 +76,50 @@ class ArrayInputTest extends TestCase
|
||||
|
||||
public function provideOptions()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array('--foo' => 'bar'),
|
||||
array(new InputOption('foo')),
|
||||
array('foo' => 'bar'),
|
||||
return [
|
||||
[
|
||||
['--foo' => 'bar'],
|
||||
[new InputOption('foo')],
|
||||
['foo' => 'bar'],
|
||||
'->parse() parses long options',
|
||||
),
|
||||
array(
|
||||
array('--foo' => 'bar'),
|
||||
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')),
|
||||
array('foo' => 'bar'),
|
||||
],
|
||||
[
|
||||
['--foo' => 'bar'],
|
||||
[new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')],
|
||||
['foo' => 'bar'],
|
||||
'->parse() parses long options with a default value',
|
||||
),
|
||||
array(
|
||||
array(),
|
||||
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')),
|
||||
array('foo' => 'default'),
|
||||
],
|
||||
[
|
||||
[],
|
||||
[new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')],
|
||||
['foo' => 'default'],
|
||||
'->parse() uses the default value for long options with value optional which are not passed',
|
||||
),
|
||||
array(
|
||||
array('--foo' => null),
|
||||
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')),
|
||||
array('foo' => null),
|
||||
],
|
||||
[
|
||||
['--foo' => null],
|
||||
[new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')],
|
||||
['foo' => null],
|
||||
'->parse() parses long options with a default value',
|
||||
),
|
||||
array(
|
||||
array('-f' => 'bar'),
|
||||
array(new InputOption('foo', 'f')),
|
||||
array('foo' => 'bar'),
|
||||
],
|
||||
[
|
||||
['-f' => 'bar'],
|
||||
[new InputOption('foo', 'f')],
|
||||
['foo' => 'bar'],
|
||||
'->parse() parses short options',
|
||||
),
|
||||
array(
|
||||
array('--' => null, '-f' => 'bar'),
|
||||
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')),
|
||||
array('foo' => 'default'),
|
||||
],
|
||||
[
|
||||
['--' => null, '-f' => 'bar'],
|
||||
[new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')],
|
||||
['foo' => 'default'],
|
||||
'->parse() does not parse opts after an end of options signal',
|
||||
),
|
||||
array(
|
||||
array('--' => null),
|
||||
array(),
|
||||
array(),
|
||||
],
|
||||
[
|
||||
['--' => null],
|
||||
[],
|
||||
[],
|
||||
'->parse() does not choke on end of options signal',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,39 +139,39 @@ class ArrayInputTest extends TestCase
|
||||
|
||||
public function provideInvalidInput()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array('foo' => 'foo'),
|
||||
new InputDefinition(array(new InputArgument('name'))),
|
||||
return [
|
||||
[
|
||||
['foo' => 'foo'],
|
||||
new InputDefinition([new InputArgument('name')]),
|
||||
'The "foo" argument does not exist.',
|
||||
),
|
||||
array(
|
||||
array('--foo' => null),
|
||||
new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))),
|
||||
],
|
||||
[
|
||||
['--foo' => null],
|
||||
new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)]),
|
||||
'The "--foo" option requires a value.',
|
||||
),
|
||||
array(
|
||||
array('--foo' => 'foo'),
|
||||
],
|
||||
[
|
||||
['--foo' => 'foo'],
|
||||
new InputDefinition(),
|
||||
'The "--foo" option does not exist.',
|
||||
),
|
||||
array(
|
||||
array('-o' => 'foo'),
|
||||
],
|
||||
[
|
||||
['-o' => 'foo'],
|
||||
new InputDefinition(),
|
||||
'The "-o" option does not exist.',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
{
|
||||
$input = new ArrayInput(array('-f' => null, '-b' => 'bar', '--foo' => 'b a z', '--lala' => null, 'test' => 'Foo', 'test2' => "A\nB'C"));
|
||||
$input = new ArrayInput(['-f' => null, '-b' => 'bar', '--foo' => 'b a z', '--lala' => null, 'test' => 'Foo', 'test2' => "A\nB'C"]);
|
||||
$this->assertEquals('-f -b=bar --foo='.escapeshellarg('b a z').' --lala Foo '.escapeshellarg("A\nB'C"), (string) $input);
|
||||
|
||||
$input = new ArrayInput(array('-b' => array('bval_1', 'bval_2'), '--f' => array('fval_1', 'fval_2')));
|
||||
$input = new ArrayInput(['-b' => ['bval_1', 'bval_2'], '--f' => ['fval_1', 'fval_2']]);
|
||||
$this->assertSame('-b=bval_1 -b=bval_2 --f=fval_1 --f=fval_2', (string) $input);
|
||||
|
||||
$input = new ArrayInput(array('array_arg' => array('val_1', 'val_2')));
|
||||
$input = new ArrayInput(['array_arg' => ['val_1', 'val_2']]);
|
||||
$this->assertSame('val_1 val_2', (string) $input);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user