Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+6 -2
View File
@@ -182,8 +182,12 @@ class ArgvInputTest extends TestCase
*/
public function testInvalidInput($argv, $definition, $expectedExceptionMessage)
{
$this->expectException('RuntimeException');
$this->expectExceptionMessage($expectedExceptionMessage);
if (method_exists($this, 'expectException')) {
$this->expectException('RuntimeException');
$this->expectExceptionMessage($expectedExceptionMessage);
} else {
$this->setExpectedException('RuntimeException', $expectedExceptionMessage);
}
$input = new ArgvInput($argv);
$input->bind($definition);
+6 -2
View File
@@ -127,8 +127,12 @@ class ArrayInputTest extends TestCase
*/
public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage)
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage($expectedExceptionMessage);
if (method_exists($this, 'expectException')) {
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage($expectedExceptionMessage);
} else {
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
}
new ArrayInput($parameters, $definition);
}
+12 -18
View File
@@ -38,22 +38,12 @@ class InputArgumentTest extends TestCase
}
/**
* @dataProvider provideInvalidModes
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Argument mode "-1" is not valid.
*/
public function testInvalidModes($mode)
public function testInvalidModes()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage(sprintf('Argument mode "%s" is not valid.', $mode));
new InputArgument('foo', $mode);
}
public function provideInvalidModes()
{
return [
['ANOTHER_ONE'],
[-1],
];
new InputArgument('foo', '-1');
}
public function testIsArray()
@@ -91,18 +81,22 @@ class InputArgumentTest extends TestCase
$this->assertEquals([1, 2], $argument->getDefault(), '->setDefault() changes the default value');
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage Cannot set a default value except for InputArgument::OPTIONAL mode.
*/
public function testSetDefaultWithRequiredArgument()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('Cannot set a default value except for InputArgument::OPTIONAL mode.');
$argument = new InputArgument('foo', InputArgument::REQUIRED);
$argument->setDefault('default');
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage A default value for an array argument must be an array.
*/
public function testSetDefaultWithArrayArgument()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('A default value for an array argument must be an array.');
$argument = new InputArgument('foo', InputArgument::IS_ARRAY);
$argument->setDefault('default');
}
+39 -21
View File
@@ -20,7 +20,6 @@ class InputDefinitionTest extends TestCase
{
protected static $fixtures;
protected $multi;
protected $foo;
protected $bar;
protected $foo1;
@@ -87,10 +86,12 @@ class InputDefinitionTest extends TestCase
$this->assertEquals(['foo' => $this->foo, 'bar' => $this->bar], $definition->getArguments(), '->addArgument() adds a InputArgument object');
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage An argument with name "foo" already exists.
*/
public function testArgumentsMustHaveDifferentNames()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('An argument with name "foo" already exists.');
$this->initializeArguments();
$definition = new InputDefinition();
@@ -98,10 +99,12 @@ class InputDefinitionTest extends TestCase
$definition->addArgument($this->foo1);
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage Cannot add an argument after an array argument.
*/
public function testArrayArgumentHasToBeLast()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('Cannot add an argument after an array argument.');
$this->initializeArguments();
$definition = new InputDefinition();
@@ -109,10 +112,12 @@ class InputDefinitionTest extends TestCase
$definition->addArgument(new InputArgument('anotherbar'));
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage Cannot add a required argument after an optional one.
*/
public function testRequiredArgumentCannotFollowAnOptionalOne()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('Cannot add a required argument after an optional one.');
$this->initializeArguments();
$definition = new InputDefinition();
@@ -129,10 +134,12 @@ class InputDefinitionTest extends TestCase
$this->assertEquals($this->foo, $definition->getArgument('foo'), '->getArgument() returns a InputArgument by its name');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "bar" argument does not exist.
*/
public function testGetInvalidArgument()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The "bar" argument does not exist.');
$this->initializeArguments();
$definition = new InputDefinition();
@@ -199,10 +206,12 @@ class InputDefinitionTest extends TestCase
$this->assertEquals(['bar' => $this->bar], $definition->getOptions(), '->setOptions() clears all InputOption objects');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "-f" option does not exist.
*/
public function testSetOptionsClearsOptions()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The "-f" option does not exist.');
$this->initializeOptions();
$definition = new InputDefinition([$this->foo]);
@@ -231,10 +240,12 @@ class InputDefinitionTest extends TestCase
$this->assertEquals(['foo' => $this->foo, 'bar' => $this->bar], $definition->getOptions(), '->addOption() adds a InputOption object');
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage An option named "foo" already exists.
*/
public function testAddDuplicateOption()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('An option named "foo" already exists.');
$this->initializeOptions();
$definition = new InputDefinition();
@@ -242,10 +253,12 @@ class InputDefinitionTest extends TestCase
$definition->addOption($this->foo2);
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage An option with shortcut "f" already exists.
*/
public function testAddDuplicateShortcutOption()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('An option with shortcut "f" already exists.');
$this->initializeOptions();
$definition = new InputDefinition();
@@ -261,10 +274,12 @@ class InputDefinitionTest extends TestCase
$this->assertEquals($this->foo, $definition->getOption('foo'), '->getOption() returns a InputOption by its name');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "--bar" option does not exist.
*/
public function testGetInvalidOption()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The "--bar" option does not exist.');
$this->initializeOptions();
$definition = new InputDefinition([$this->foo]);
@@ -306,10 +321,12 @@ class InputDefinitionTest extends TestCase
$this->assertEquals($this->multi, $definition->getOptionForShortcut('mmm'), '->getOptionForShortcut() returns a InputOption by its shortcut');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "-l" option does not exist.
*/
public function testGetOptionForInvalidShortcut()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The "-l" option does not exist.');
$this->initializeOptions();
$definition = new InputDefinition([$this->foo]);
@@ -357,8 +374,9 @@ class InputDefinitionTest extends TestCase
[new InputDefinition([new InputArgument('foo', InputArgument::REQUIRED)]), '<foo>', 'puts arguments in angle brackets'],
[new InputDefinition([new InputArgument('foo')]), '[<foo>]', 'puts optional arguments in square brackets'],
[new InputDefinition([new InputArgument('foo', InputArgument::IS_ARRAY)]), '[<foo>]...', 'uses an ellipsis for array arguments'],
[new InputDefinition([new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY)]), '<foo> (<foo>)...', 'uses parenthesis and ellipsis for required array arguments'],
[new InputDefinition([new InputArgument('foo'), new InputArgument('bar')]), '[<foo> [<bar>]]', 'chains optional arguments inside brackets'],
[new InputDefinition([new InputArgument('foo', InputArgument::IS_ARRAY)]), '[<foo>...]', 'uses an ellipsis for array arguments'],
[new InputDefinition([new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY)]), '<foo>...', 'uses an ellipsis for required array arguments'],
[new InputDefinition([new InputOption('foo'), new InputArgument('foo', InputArgument::REQUIRED)]), '[--foo] [--] <foo>', 'puts [--] between options and arguments'],
];
+25 -23
View File
@@ -24,10 +24,12 @@ class InputOptionTest extends TestCase
$this->assertEquals('foo', $option->getName(), '__construct() removes the leading -- of the option name');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.
*/
public function testArrayModeWithoutValue()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
new InputOption('foo', 'f', InputOption::VALUE_IS_ARRAY);
}
@@ -72,39 +74,35 @@ class InputOptionTest extends TestCase
}
/**
* @dataProvider provideInvalidModes
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Option mode "-1" is not valid.
*/
public function testInvalidModes($mode)
public function testInvalidModes()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage(sprintf('Option mode "%s" is not valid.', $mode));
new InputOption('foo', 'f', $mode);
}
public function provideInvalidModes()
{
return [
['ANOTHER_ONE'],
[-1],
];
new InputOption('foo', 'f', '-1');
}
/**
* @expectedException \InvalidArgumentException
*/
public function testEmptyNameIsInvalid()
{
$this->expectException('InvalidArgumentException');
new InputOption('');
}
/**
* @expectedException \InvalidArgumentException
*/
public function testDoubleDashNameIsInvalid()
{
$this->expectException('InvalidArgumentException');
new InputOption('--');
}
/**
* @expectedException \InvalidArgumentException
*/
public function testSingleDashOptionIsInvalid()
{
$this->expectException('InvalidArgumentException');
new InputOption('foo', '-');
}
@@ -153,18 +151,22 @@ class InputOptionTest extends TestCase
$this->assertEquals([1, 2], $option->getDefault(), '->setDefault() changes the default value');
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage Cannot set a default value when using InputOption::VALUE_NONE mode.
*/
public function testDefaultValueWithValueNoneMode()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('Cannot set a default value when using InputOption::VALUE_NONE mode.');
$option = new InputOption('foo', 'f', InputOption::VALUE_NONE);
$option->setDefault('default');
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage A default value for an array option must be an array.
*/
public function testDefaultValueWithIsArrayMode()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('A default value for an array option must be an array.');
$option = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY);
$option->setDefault('default');
}
+24 -12
View File
@@ -47,18 +47,22 @@ class InputTest extends TestCase
$this->assertEquals(['name' => 'foo', 'bar' => null], $input->getOptions(), '->getOptions() returns all option values');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "foo" option does not exist.
*/
public function testSetInvalidOption()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The "foo" option does not exist.');
$input = new ArrayInput(['--name' => 'foo'], new InputDefinition([new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')]));
$input->setOption('foo', 'bar');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "foo" option does not exist.
*/
public function testGetInvalidOption()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The "foo" option does not exist.');
$input = new ArrayInput(['--name' => 'foo'], new InputDefinition([new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')]));
$input->getOption('foo');
}
@@ -77,35 +81,43 @@ class InputTest extends TestCase
$this->assertEquals(['name' => 'foo', 'bar' => 'default'], $input->getArguments(), '->getArguments() returns all argument values, even optional ones');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "foo" argument does not exist.
*/
public function testSetInvalidArgument()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The "foo" argument does not exist.');
$input = new ArrayInput(['name' => 'foo'], new InputDefinition([new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')]));
$input->setArgument('foo', 'bar');
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "foo" argument does not exist.
*/
public function testGetInvalidArgument()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The "foo" argument does not exist.');
$input = new ArrayInput(['name' => 'foo'], new InputDefinition([new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')]));
$input->getArgument('foo');
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Not enough arguments (missing: "name").
*/
public function testValidateWithMissingArguments()
{
$this->expectException('RuntimeException');
$this->expectExceptionMessage('Not enough arguments (missing: "name").');
$input = new ArrayInput([]);
$input->bind(new InputDefinition([new InputArgument('name', InputArgument::REQUIRED)]));
$input->validate();
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Not enough arguments (missing: "name").
*/
public function testValidateWithMissingRequiredArguments()
{
$this->expectException('RuntimeException');
$this->expectExceptionMessage('Not enough arguments (missing: "name").');
$input = new ArrayInput(['bar' => 'baz']);
$input->bind(new InputDefinition([new InputArgument('name', InputArgument::REQUIRED), new InputArgument('bar', InputArgument::OPTIONAL)]));
$input->validate();