mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-03 13:40:00 +09:00
update to laravel 5.7 and try getting autologin saved
This commit is contained in:
207
vendor/symfony/console/Tests/ApplicationTest.php
vendored
207
vendor/symfony/console/Tests/ApplicationTest.php
vendored
@@ -16,24 +16,24 @@ use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\CommandLoader\FactoryCommandLoader;
|
||||
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleErrorEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
use Symfony\Component\Console\Exception\NamespaceNotFoundException;
|
||||
use Symfony\Component\Console\Helper\FormatterHelper;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
use Symfony\Component\Console\Tester\ApplicationTester;
|
||||
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleErrorEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
||||
@@ -57,6 +57,7 @@ class ApplicationTest extends TestCase
|
||||
require_once self::$fixturesPath.'/BarBucCommand.php';
|
||||
require_once self::$fixturesPath.'/FooSubnamespaced1Command.php';
|
||||
require_once self::$fixturesPath.'/FooSubnamespaced2Command.php';
|
||||
require_once self::$fixturesPath.'/FooWithoutAliasCommand.php';
|
||||
require_once self::$fixturesPath.'/TestTiti.php';
|
||||
require_once self::$fixturesPath.'/TestToto.php';
|
||||
}
|
||||
@@ -276,10 +277,10 @@ class ApplicationTest extends TestCase
|
||||
$expectedMsg = "The namespace \"f\" is ambiguous.\nDid you mean one of these?\n foo\n foo1";
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(CommandNotFoundException::class);
|
||||
$this->expectException(NamespaceNotFoundException::class);
|
||||
$this->expectExceptionMessage($expectedMsg);
|
||||
} else {
|
||||
$this->setExpectedException(CommandNotFoundException::class, $expectedMsg);
|
||||
$this->setExpectedException(NamespaceNotFoundException::class, $expectedMsg);
|
||||
}
|
||||
|
||||
$application->findNamespace('f');
|
||||
@@ -294,7 +295,7 @@ class ApplicationTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException
|
||||
* @expectedException \Symfony\Component\Console\Exception\NamespaceNotFoundException
|
||||
* @expectedExceptionMessage There are no commands defined in the "bar" namespace.
|
||||
*/
|
||||
public function testFindInvalidNamespace()
|
||||
@@ -458,6 +459,52 @@ class ApplicationTest extends TestCase
|
||||
$application->find($name);
|
||||
}
|
||||
|
||||
public function testDontRunAlternativeNamespaceName()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->add(new \Foo1Command());
|
||||
$application->setAutoExit(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'foos:bar1'), array('decorated' => false));
|
||||
$this->assertSame('
|
||||
|
||||
There are no commands defined in the "foos" namespace.
|
||||
|
||||
Did you mean this?
|
||||
foo
|
||||
|
||||
|
||||
', $tester->getDisplay(true));
|
||||
}
|
||||
|
||||
public function testCanRunAlternativeCommandName()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->add(new \FooWithoutAliasCommand());
|
||||
$application->setAutoExit(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->setInputs(array('y'));
|
||||
$tester->run(array('command' => 'foos'), array('decorated' => false));
|
||||
$display = trim($tester->getDisplay(true));
|
||||
$this->assertContains('Command "foos" is not defined', $display);
|
||||
$this->assertContains('Do you want to run "foo" instead? (yes/no) [no]:', $display);
|
||||
$this->assertContains('called', $display);
|
||||
}
|
||||
|
||||
public function testDontRunAlternativeCommandName()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->add(new \FooWithoutAliasCommand());
|
||||
$application->setAutoExit(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->setInputs(array('n'));
|
||||
$exitCode = $tester->run(array('command' => 'foos'), array('decorated' => false));
|
||||
$this->assertSame(1, $exitCode);
|
||||
$display = trim($tester->getDisplay(true));
|
||||
$this->assertContains('Command "foos" is not defined', $display);
|
||||
$this->assertContains('Do you want to run "foo" instead? (yes/no) [no]:', $display);
|
||||
}
|
||||
|
||||
public function provideInvalidCommandNamesSingle()
|
||||
{
|
||||
return array(
|
||||
@@ -575,7 +622,8 @@ class ApplicationTest extends TestCase
|
||||
$application->find('foo2:command');
|
||||
$this->fail('->find() throws a CommandNotFoundException if namespace does not exist');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if namespace does not exist');
|
||||
$this->assertInstanceOf('Symfony\Component\Console\Exception\NamespaceNotFoundException', $e, '->find() throws a NamespaceNotFoundException if namespace does not exist');
|
||||
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, 'NamespaceNotFoundException extends from CommandNotFoundException');
|
||||
$this->assertCount(3, $e->getAlternatives());
|
||||
$this->assertContains('foo', $e->getAlternatives());
|
||||
$this->assertContains('foo1', $e->getAlternatives());
|
||||
@@ -912,6 +960,30 @@ class ApplicationTest extends TestCase
|
||||
$this->assertSame(4, $exitCode, '->run() returns integer exit code extracted from raised exception');
|
||||
}
|
||||
|
||||
public function testRunDispatchesIntegerExitCode()
|
||||
{
|
||||
$passedRightValue = false;
|
||||
|
||||
// We can assume here that some other test asserts that the event is dispatched at all
|
||||
$dispatcher = new EventDispatcher();
|
||||
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) {
|
||||
$passedRightValue = (4 === $event->getExitCode());
|
||||
});
|
||||
|
||||
$application = new Application();
|
||||
$application->setDispatcher($dispatcher);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||
throw new \Exception('', 4);
|
||||
});
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'test'));
|
||||
|
||||
$this->assertTrue($passedRightValue, '-> exit code 4 was passed in the console.terminate event');
|
||||
}
|
||||
|
||||
public function testRunReturnsExitCodeOneForExceptionCodeZero()
|
||||
{
|
||||
$exception = new \Exception('', 0);
|
||||
@@ -927,6 +999,30 @@ class ApplicationTest extends TestCase
|
||||
$this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is 0');
|
||||
}
|
||||
|
||||
public function testRunDispatchesExitCodeOneForExceptionCodeZero()
|
||||
{
|
||||
$passedRightValue = false;
|
||||
|
||||
// We can assume here that some other test asserts that the event is dispatched at all
|
||||
$dispatcher = new EventDispatcher();
|
||||
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) {
|
||||
$passedRightValue = (1 === $event->getExitCode());
|
||||
});
|
||||
|
||||
$application = new Application();
|
||||
$application->setDispatcher($dispatcher);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||
throw new \Exception();
|
||||
});
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'test'));
|
||||
|
||||
$this->assertTrue($passedRightValue, '-> exit code 1 was passed in the console.terminate event');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage An option with shortcut "e" already exists.
|
||||
@@ -1164,9 +1260,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertContains('before.error.after.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testRunWithError()
|
||||
{
|
||||
$application = new Application();
|
||||
@@ -1235,36 +1328,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertEquals(1, $tester->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "ConsoleEvents::EXCEPTION" event is deprecated since Symfony 3.3 and will be removed in 4.0. Listen to the "ConsoleEvents::ERROR" event instead.
|
||||
*/
|
||||
public function testLegacyExceptionListenersAreStillTriggered()
|
||||
{
|
||||
$dispatcher = $this->getDispatcher();
|
||||
$dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) {
|
||||
$event->getOutput()->write('caught.');
|
||||
|
||||
$event->setException(new \RuntimeException('replaced in caught.'));
|
||||
});
|
||||
|
||||
$application = new Application();
|
||||
$application->setDispatcher($dispatcher);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||
throw new \RuntimeException('foo');
|
||||
});
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'foo'));
|
||||
$this->assertContains('before.caught.error.after.', $tester->getDisplay());
|
||||
$this->assertContains('replaced in caught.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testErrorIsRethrownIfNotHandledByConsoleErrorEvent()
|
||||
{
|
||||
$application = new Application();
|
||||
@@ -1287,7 +1350,6 @@ class ApplicationTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage error
|
||||
*/
|
||||
@@ -1309,9 +1371,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertContains('before.dym.error.after.', $tester->getDisplay(), 'The PHP Error did not dispached events');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testRunDispatchesAllEventsWithError()
|
||||
{
|
||||
$application = new Application();
|
||||
@@ -1329,9 +1388,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertContains('before.dym.error.after.', $tester->getDisplay(), 'The PHP Error did not dispached events');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testRunWithErrorFailingStatusCode()
|
||||
{
|
||||
$application = new Application();
|
||||
@@ -1422,24 +1478,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertEquals('some test value', $extraValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testTerminalDimensions()
|
||||
{
|
||||
$application = new Application();
|
||||
$originalDimensions = $application->getTerminalDimensions();
|
||||
$this->assertCount(2, $originalDimensions);
|
||||
|
||||
$width = 80;
|
||||
if ($originalDimensions[0] == $width) {
|
||||
$width = 100;
|
||||
}
|
||||
|
||||
$application->setTerminalDimensions($width, 80);
|
||||
$this->assertSame(array($width, 80), $application->getTerminalDimensions());
|
||||
}
|
||||
|
||||
public function testSetRunCustomDefaultCommand()
|
||||
{
|
||||
$command = new \FooCommand();
|
||||
@@ -1592,9 +1630,6 @@ class ApplicationTest extends TestCase
|
||||
return $dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEnabled()
|
||||
{
|
||||
$application = new Application();
|
||||
@@ -1615,6 +1650,34 @@ class ApplicationTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage foo
|
||||
*/
|
||||
public function testThrowingErrorListener()
|
||||
{
|
||||
$dispatcher = $this->getDispatcher();
|
||||
$dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) {
|
||||
throw new \RuntimeException('foo');
|
||||
});
|
||||
|
||||
$dispatcher->addListener('console.command', function () {
|
||||
throw new \RuntimeException('bar');
|
||||
});
|
||||
|
||||
$application = new Application();
|
||||
$application->setDispatcher($dispatcher);
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
|
||||
$application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||
$output->write('foo.');
|
||||
});
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'foo'));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
putenv('SHELL_VERBOSITY');
|
||||
|
||||
Reference in New Issue
Block a user