Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
046bc97
commit 50950e6
Showing
1 changed file
with
44 additions
and
45 deletions.
There are no files selected for viewing
89 changes: 44 additions & 45 deletions
89
src/Symfony/Component/Console/Tests/Tester/Constraint/CommandIsFaultyTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,44 @@ | ||
<?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\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(); | ||
} | ||
} | ||
<?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\Tests\Tester\Constraint; | ||
|
||
use PHPUnit\Framework\ExpectationFailedException; | ||
use PHPUnit\Framework\TestCase; | ||
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(); | ||
} | ||
} |