mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-03 05:29:53 +09:00
Update to laravel 7
This commit is contained in:
@@ -29,8 +29,6 @@ class ApplicationTester
|
||||
use TesterTrait;
|
||||
|
||||
private $application;
|
||||
private $input;
|
||||
private $statusCode;
|
||||
|
||||
public function __construct(Application $application)
|
||||
{
|
||||
@@ -47,31 +45,21 @@ class ApplicationTester
|
||||
* * verbosity: Sets the output verbosity flag
|
||||
* * capture_stderr_separately: Make output of stdOut and stdErr separately available
|
||||
*
|
||||
* @param array $input An array of arguments and options
|
||||
* @param array $options An array of options
|
||||
*
|
||||
* @return int The command exit code
|
||||
*/
|
||||
public function run(array $input, $options = [])
|
||||
public function run(array $input, array $options = [])
|
||||
{
|
||||
$this->input = new ArrayInput($input);
|
||||
if (isset($options['interactive'])) {
|
||||
$this->input->setInteractive($options['interactive']);
|
||||
}
|
||||
|
||||
$shellInteractive = getenv('SHELL_INTERACTIVE');
|
||||
|
||||
if ($this->inputs) {
|
||||
$this->input->setStream(self::createStream($this->inputs));
|
||||
putenv('SHELL_INTERACTIVE=1');
|
||||
}
|
||||
|
||||
$this->initOutput($options);
|
||||
|
||||
$this->statusCode = $this->application->run($this->input, $this->output);
|
||||
|
||||
putenv($shellInteractive ? "SHELL_INTERACTIVE=$shellInteractive" : 'SHELL_INTERACTIVE');
|
||||
|
||||
return $this->statusCode;
|
||||
return $this->statusCode = $this->application->run($this->input, $this->output);
|
||||
}
|
||||
}
|
||||
|
||||
56
vendor/symfony/console/Tester/CommandCompletionTester.php
vendored
Normal file
56
vendor/symfony/console/Tester/CommandCompletionTester.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Completion\CompletionInput;
|
||||
use Symfony\Component\Console\Completion\CompletionSuggestions;
|
||||
|
||||
/**
|
||||
* Eases the testing of command completion.
|
||||
*
|
||||
* @author Jérôme Tamarelle <jerome@tamarelle.net>
|
||||
*/
|
||||
class CommandCompletionTester
|
||||
{
|
||||
private $command;
|
||||
|
||||
public function __construct(Command $command)
|
||||
{
|
||||
$this->command = $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create completion suggestions from input tokens.
|
||||
*/
|
||||
public function complete(array $input): array
|
||||
{
|
||||
$currentIndex = \count($input);
|
||||
if ('' === end($input)) {
|
||||
array_pop($input);
|
||||
}
|
||||
array_unshift($input, $this->command->getName());
|
||||
|
||||
$completionInput = CompletionInput::fromTokens($input, $currentIndex);
|
||||
$completionInput->bind($this->command->getDefinition());
|
||||
$suggestions = new CompletionSuggestions();
|
||||
|
||||
$this->command->complete($completionInput, $suggestions);
|
||||
|
||||
$options = [];
|
||||
foreach ($suggestions->getOptionSuggestions() as $option) {
|
||||
$options[] = '--'.$option->getName();
|
||||
}
|
||||
|
||||
return array_map('strval', array_merge($options, $suggestions->getValueSuggestions()));
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,6 @@ class CommandTester
|
||||
use TesterTrait;
|
||||
|
||||
private $command;
|
||||
private $input;
|
||||
private $statusCode;
|
||||
|
||||
public function __construct(Command $command)
|
||||
{
|
||||
|
||||
55
vendor/symfony/console/Tester/Constraint/CommandIsSuccessful.php
vendored
Normal file
55
vendor/symfony/console/Tester/Constraint/CommandIsSuccessful.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tester\Constraint;
|
||||
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
final class CommandIsSuccessful extends Constraint
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return 'is successful';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return Command::SUCCESS === $other;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
{
|
||||
return 'the command '.$this->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function additionalFailureDescription($other): string
|
||||
{
|
||||
$mapping = [
|
||||
Command::FAILURE => 'Command failed.',
|
||||
Command::INVALID => 'Command was invalid.',
|
||||
];
|
||||
|
||||
return $mapping[$other] ?? sprintf('Command returned exit status %d.', $other);
|
||||
}
|
||||
}
|
||||
46
vendor/symfony/console/Tester/TesterTrait.php
vendored
46
vendor/symfony/console/Tester/TesterTrait.php
vendored
@@ -11,10 +11,12 @@
|
||||
|
||||
namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
use Symfony\Component\Console\Tester\Constraint\CommandIsSuccessful;
|
||||
|
||||
/**
|
||||
* @author Amrouche Hamza <hamza.simperfit@gmail.com>
|
||||
@@ -25,15 +27,19 @@ trait TesterTrait
|
||||
private $output;
|
||||
private $inputs = [];
|
||||
private $captureStreamsIndependently = false;
|
||||
/** @var InputInterface */
|
||||
private $input;
|
||||
/** @var int */
|
||||
private $statusCode;
|
||||
|
||||
/**
|
||||
* Gets the display returned by the last execution of the command or application.
|
||||
*
|
||||
* @param bool $normalize Whether to normalize end of lines to \n or not
|
||||
* @throws \RuntimeException If it's called before the execute method
|
||||
*
|
||||
* @return string The display
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplay($normalize = false)
|
||||
public function getDisplay(bool $normalize = false)
|
||||
{
|
||||
if (null === $this->output) {
|
||||
throw new \RuntimeException('Output not initialized, did you execute the command before requesting the display?');
|
||||
@@ -44,7 +50,7 @@ trait TesterTrait
|
||||
$display = stream_get_contents($this->output->getStream());
|
||||
|
||||
if ($normalize) {
|
||||
$display = str_replace(PHP_EOL, "\n", $display);
|
||||
$display = str_replace(\PHP_EOL, "\n", $display);
|
||||
}
|
||||
|
||||
return $display;
|
||||
@@ -57,7 +63,7 @@ trait TesterTrait
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorOutput($normalize = false)
|
||||
public function getErrorOutput(bool $normalize = false)
|
||||
{
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.');
|
||||
@@ -68,7 +74,7 @@ trait TesterTrait
|
||||
$display = stream_get_contents($this->output->getErrorOutput()->getStream());
|
||||
|
||||
if ($normalize) {
|
||||
$display = str_replace(PHP_EOL, "\n", $display);
|
||||
$display = str_replace(\PHP_EOL, "\n", $display);
|
||||
}
|
||||
|
||||
return $display;
|
||||
@@ -77,7 +83,7 @@ trait TesterTrait
|
||||
/**
|
||||
* Gets the input instance used by the last execution of the command or application.
|
||||
*
|
||||
* @return InputInterface The current input instance
|
||||
* @return InputInterface
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
@@ -87,7 +93,7 @@ trait TesterTrait
|
||||
/**
|
||||
* Gets the output instance used by the last execution of the command or application.
|
||||
*
|
||||
* @return OutputInterface The current output instance
|
||||
* @return OutputInterface
|
||||
*/
|
||||
public function getOutput()
|
||||
{
|
||||
@@ -97,20 +103,31 @@ trait TesterTrait
|
||||
/**
|
||||
* Gets the status code returned by the last execution of the command or application.
|
||||
*
|
||||
* @return int The status code
|
||||
* @throws \RuntimeException If it's called before the execute method
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
if (null === $this->statusCode) {
|
||||
throw new \RuntimeException('Status code not initialized, did you execute the command before requesting the status code?');
|
||||
}
|
||||
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
public function assertCommandIsSuccessful(string $message = ''): void
|
||||
{
|
||||
Assert::assertThat($this->statusCode, new CommandIsSuccessful(), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user inputs.
|
||||
*
|
||||
* @param array $inputs An array of strings representing each input
|
||||
* passed to the command input stream
|
||||
*
|
||||
* @return self
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputs(array $inputs)
|
||||
{
|
||||
@@ -141,8 +158,8 @@ trait TesterTrait
|
||||
}
|
||||
} else {
|
||||
$this->output = new ConsoleOutput(
|
||||
isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL,
|
||||
isset($options['decorated']) ? $options['decorated'] : null
|
||||
$options['verbosity'] ?? ConsoleOutput::VERBOSITY_NORMAL,
|
||||
$options['decorated'] ?? null
|
||||
);
|
||||
|
||||
$errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
@@ -162,12 +179,15 @@ trait TesterTrait
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*/
|
||||
private static function createStream(array $inputs)
|
||||
{
|
||||
$stream = fopen('php://memory', 'r+', false);
|
||||
|
||||
foreach ($inputs as $input) {
|
||||
fwrite($stream, $input.PHP_EOL);
|
||||
fwrite($stream, $input.\PHP_EOL);
|
||||
}
|
||||
|
||||
rewind($stream);
|
||||
|
||||
Reference in New Issue
Block a user