Update to laravel 7

This commit is contained in:
KodeStar
2022-03-10 11:54:29 +00:00
parent 61a5a1a8b0
commit f9a19fce91
7170 changed files with 274189 additions and 283773 deletions

View File

@@ -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);