/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/Console/Tester/ConsoleAssertionsTrait.php
64 строки
2 KB
Nicolas Grekas
[FrameworkBundle] Remove hard-dep of KernelTestCase on ConsoleAssertionsTrait
06 мар 2026, 11:53
06 мар 2026, 11:53
23b11e5
Код
Авторство
О чём код?
<?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\Tester\Constraint\CommandFailed; use Symfony\Component\Console\Tester\Constraint\CommandIsInvalid; use Symfony\Component\Console\Tester\Constraint\CommandIsSuccessful; /** * @psalm-require-extends \PHPUnit\Framework\TestCase * * @author Théo FIDRY <theo.fidry@gmail.com> */ trait ConsoleAssertionsTrait { public function assertCommandIsSuccessful(ExecutionResult $result, string $message = ''): void { $this->assertThat($result->statusCode, new CommandIsSuccessful(), $message); } public function assertCommandFailed(ExecutionResult $result, string $message = ''): void { $this->assertThat($result->statusCode, new CommandFailed(), $message); } public function assertCommandIsInvalid(ExecutionResult $result, string $message = ''): void { $this->assertThat($result->statusCode, new CommandIsInvalid(), $message); } public function assertCommandResultEquals(ExecutionResult $result, ?int $expectedStatusCode = null, ?string $expectedOutput = null, ?string $expectedErrorOutput = null, ?string $expectedDisplay = null, string $message = ''): void { $expected = []; $actual = []; if (null !== $expectedStatusCode) { $expected['statusCode'] = $expectedStatusCode; $actual['statusCode'] = $result->statusCode; } if (null !== $expectedOutput) { $expected['output'] = $expectedOutput; $actual['output'] = $result->getOutput(); } if (null !== $expectedErrorOutput) { $expected['errorOutput'] = $expectedErrorOutput; $actual['errorOutput'] = $result->getErrorOutput(); } if (null !== $expectedDisplay) { $expected['display'] = $expectedDisplay; $actual['display'] = $result->getDisplay(); } $this->assertEquals($expected, $actual, $message); } }