/
CommandIsFaultyTest.php
45 lines (36 loc) · 1.35 KB
/
CommandIsFaultyTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* This file is part of the Symfony package.
*
* (c) Raphael Stolt <raphael.stolt@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Console\Tests\Tester\Constraint;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestFailure;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\Constraint\CommandIsFaulty;
final class CommandIsFaultyTest extends TestCase
{
public function testConstraint()
{
$constraint = new CommandIsFaulty();
$this->assertFalse($constraint->evaluate(Command::SUCCESS, returnResult: true));
$this->assertTrue($constraint->evaluate(Command::FAILURE, returnResult: true));
$this->assertTrue($constraint->evaluate(Command::INVALID, returnResult: true));
}
public function testSuccessfulCommand()
{
$constraint = new CommandIsFaulty();
try {
$constraint->evaluate(Command::SUCCESS);
} catch (ExpectationFailedException $e) {
$this->assertStringContainsString('Failed asserting that the command is faulty.', $e->getMessage());
return;
}
$this->fail();
}
}