Update vendored libs

This commit is contained in:
Frédéric Guillot
2020-06-08 22:46:20 -07:00
parent dfb0a2d915
commit f60e4a0c59
292 changed files with 9402 additions and 9487 deletions

View File

@@ -12,16 +12,16 @@
namespace Symfony\Component\Console\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Tester\CommandTester;
class CommandTest extends TestCase
@@ -71,7 +71,7 @@ class CommandTest extends TestCase
$ret = $command->setDefinition($definition = new InputDefinition());
$this->assertEquals($command, $ret, '->setDefinition() implements a fluent interface');
$this->assertEquals($definition, $command->getDefinition(), '->setDefinition() sets the current InputDefinition instance');
$command->setDefinition(array(new InputArgument('foo'), new InputOption('bar')));
$command->setDefinition([new InputArgument('foo'), new InputOption('bar')]);
$this->assertTrue($command->getDefinition()->hasArgument('foo'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument');
$this->assertTrue($command->getDefinition()->hasOption('bar'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument');
$command->setDefinition(new InputDefinition());
@@ -130,10 +130,10 @@ class CommandTest extends TestCase
public function provideInvalidCommandNames()
{
return array(
array(''),
array('foo:'),
);
return [
[''],
['foo:'],
];
}
public function testGetSetDescription()
@@ -166,15 +166,23 @@ class CommandTest extends TestCase
$command = new \TestCommand();
$command->setHelp('');
$this->assertContains('description', $command->getProcessedHelp(), '->getProcessedHelp() falls back to the description');
$command = new \TestCommand();
$command->setHelp('The %command.name% command does... Example: php %command.full_name%.');
$application = new Application();
$application->add($command);
$application->setDefaultCommand('namespace:name', true);
$this->assertContains('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly in single command applications');
$this->assertNotContains('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name% in single command applications');
}
public function testGetSetAliases()
{
$command = new \TestCommand();
$this->assertEquals(array('name'), $command->getAliases(), '->getAliases() returns the aliases');
$ret = $command->setAliases(array('name1'));
$this->assertEquals(['name'], $command->getAliases(), '->getAliases() returns the aliases');
$ret = $command->setAliases(['name1']);
$this->assertEquals($command, $ret, '->setAliases() implements a fluent interface');
$this->assertEquals(array('name1'), $command->getAliases(), '->setAliases() sets the aliases');
$this->assertEquals(['name1'], $command->getAliases(), '->setAliases() sets the aliases');
}
public function testSetAliasesNull()
@@ -223,11 +231,11 @@ class CommandTest extends TestCase
public function testMergeApplicationDefinition()
{
$application1 = new Application();
$application1->getDefinition()->addArguments(array(new InputArgument('foo')));
$application1->getDefinition()->addOptions(array(new InputOption('bar')));
$application1->getDefinition()->addArguments([new InputArgument('foo')]);
$application1->getDefinition()->addOptions([new InputOption('bar')]);
$command = new \TestCommand();
$command->setApplication($application1);
$command->setDefinition($definition = new InputDefinition(array(new InputArgument('bar'), new InputOption('foo'))));
$command->setDefinition($definition = new InputDefinition([new InputArgument('bar'), new InputOption('foo')]));
$r = new \ReflectionObject($command);
$m = $r->getMethod('mergeApplicationDefinition');
@@ -245,11 +253,11 @@ class CommandTest extends TestCase
public function testMergeApplicationDefinitionWithoutArgsThenWithArgsAddsArgs()
{
$application1 = new Application();
$application1->getDefinition()->addArguments(array(new InputArgument('foo')));
$application1->getDefinition()->addOptions(array(new InputOption('bar')));
$application1->getDefinition()->addArguments([new InputArgument('foo')]);
$application1->getDefinition()->addOptions([new InputOption('bar')]);
$command = new \TestCommand();
$command->setApplication($application1);
$command->setDefinition($definition = new InputDefinition(array()));
$command->setDefinition($definition = new InputDefinition([]));
$r = new \ReflectionObject($command);
$m = $r->getMethod('mergeApplicationDefinition');
@@ -269,7 +277,7 @@ class CommandTest extends TestCase
{
$tester = new CommandTester(new \TestCommand());
$tester->execute(array(), array('interactive' => true));
$tester->execute([], ['interactive' => true]);
$this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive');
}
@@ -278,7 +286,7 @@ class CommandTest extends TestCase
{
$tester = new CommandTester(new \TestCommand());
$tester->execute(array(), array('interactive' => false));
$tester->execute([], ['interactive' => false]);
$this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive');
}
@@ -301,7 +309,7 @@ class CommandTest extends TestCase
{
$command = new \TestCommand();
$tester = new CommandTester($command);
$tester->execute(array('--bar' => true));
$tester->execute(['--bar' => true]);
}
public function testRunReturnsIntegerExitCode()
@@ -310,10 +318,10 @@ class CommandTest extends TestCase
$exitCode = $command->run(new StringInput(''), new NullOutput());
$this->assertSame(0, $exitCode, '->run() returns integer exit code (treats null as 0)');
$command = $this->getMockBuilder('TestCommand')->setMethods(array('execute'))->getMock();
$command = $this->getMockBuilder('TestCommand')->setMethods(['execute'])->getMock();
$command->expects($this->once())
->method('execute')
->will($this->returnValue('2.3'));
->willReturn('2.3');
$exitCode = $command->run(new StringInput(''), new NullOutput());
$this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)');
}
@@ -340,7 +348,7 @@ class CommandTest extends TestCase
$command->setApplication(new Application());
$command->setProcessTitle('foo');
$this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
if (function_exists('cli_set_process_title')) {
if (\function_exists('cli_set_process_title')) {
if (null === @cli_get_process_title() && 'Darwin' === PHP_OS) {
$this->markTestSkipped('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.');
}
@@ -356,16 +364,16 @@ class CommandTest extends TestCase
});
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');
$tester = new CommandTester($command);
$tester->execute(array());
$tester->execute([]);
$this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay());
}
public function getSetCodeBindToClosureTests()
{
return array(
array(true, 'not bound to the command'),
array(false, 'bound to the command'),
);
return [
[true, 'not bound to the command'],
[false, 'bound to the command'],
];
}
/**
@@ -381,7 +389,7 @@ class CommandTest extends TestCase
$command = new \TestCommand();
$command->setCode($code);
$tester = new CommandTester($command);
$tester->execute(array());
$tester->execute([]);
$this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay());
}
@@ -390,15 +398,9 @@ class CommandTest extends TestCase
$command = new \TestCommand();
$command->setCode(self::createClosure());
$tester = new CommandTester($command);
$tester->execute(array());
$tester->execute([]);
if (\PHP_VERSION_ID < 70000) {
// Cannot bind static closures in PHP 5
$this->assertEquals('interact called'.PHP_EOL.'not bound'.PHP_EOL, $tester->getDisplay());
} else {
// Can bind static closures in PHP 7
$this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay());
}
$this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay());
}
private static function createClosure()
@@ -411,10 +413,10 @@ class CommandTest extends TestCase
public function testSetCodeWithNonClosureCallable()
{
$command = new \TestCommand();
$ret = $command->setCode(array($this, 'callableMethodCommand'));
$ret = $command->setCode([$this, 'callableMethodCommand']);
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');
$tester = new CommandTester($command);
$tester->execute(array());
$tester->execute([]);
$this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay());
}