CommandIsSuccessful.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace IAWP_SCOPED\Symfony\Component\Console\Tester\Constraint; |
| 12 | |
| 13 | use IAWP_SCOPED\PHPUnit\Framework\Constraint\Constraint; |
| 14 | use IAWP_SCOPED\Symfony\Component\Console\Command\Command; |
| 15 | /** @internal */ |
| 16 | final class CommandIsSuccessful extends Constraint |
| 17 | { |
| 18 | /** |
| 19 | * {@inheritdoc} |
| 20 | */ |
| 21 | public function toString() : string |
| 22 | { |
| 23 | return 'is successful'; |
| 24 | } |
| 25 | /** |
| 26 | * {@inheritdoc} |
| 27 | */ |
| 28 | protected function matches($other) : bool |
| 29 | { |
| 30 | return Command::SUCCESS === $other; |
| 31 | } |
| 32 | /** |
| 33 | * {@inheritdoc} |
| 34 | */ |
| 35 | protected function failureDescription($other) : string |
| 36 | { |
| 37 | return 'the command ' . $this->toString(); |
| 38 | } |
| 39 | /** |
| 40 | * {@inheritdoc} |
| 41 | */ |
| 42 | protected function additionalFailureDescription($other) : string |
| 43 | { |
| 44 | $mapping = [Command::FAILURE => 'Command failed.', Command::INVALID => 'Command was invalid.']; |
| 45 | return $mapping[$other] ?? \sprintf('Command returned exit status %d.', $other); |
| 46 | } |
| 47 | } |
| 48 |