Skip to content

Commit

Permalink
Utilises zenstruck/console-test
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelstolt committed Jul 18, 2024
1 parent 402feda commit 255b702
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"phlak/semver": "^4.1",
"php-mock/php-mock-phpunit": "^2.7||^1.1",
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^11.2.6||^10.5.25"
"phpunit/phpunit": "^11.2.6||^10.5.25",
"zenstruck/console-test": "^1.5"
}
}
15 changes: 8 additions & 7 deletions tests/Commands/ValidateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
use Stolt\LeanPackage\Tests\CommandTester;
use Stolt\LeanPackage\Tests\TestCase;
use Symfony\Component\Console\Application;
use Zenstruck\Console\Test\InteractsWithConsole;
use Zenstruck\Console\Test\TestCommand;

class ValidateCommandTest extends TestCase
{
use InteractsWithConsole;

/**
* @var Application
*/
Expand Down Expand Up @@ -344,11 +348,6 @@ public function gitattributesIsInSuggestedFileContent(): void
);

$command = $this->application->find('validate');
$commandTester = new CommandTester($command);
$commandTester->execute([
'command' => $command->getName(),
'directory' => WORKING_DIRECTORY,
]);

$expectedDisplay = <<<CONTENT
Warning: There is no .gitattributes file present in {$this->temporaryDirectory}.
Expand All @@ -365,8 +364,10 @@ public function gitattributesIsInSuggestedFileContent(): void
CONTENT;

$this->assertSame($expectedDisplay, $commandTester->getDisplay());
$this->assertTrue($commandTester->getStatusCode() > 0);
TestCommand::for($command)
->execute(WORKING_DIRECTORY)
->assertOutputContains($expectedDisplay)
->assertStatusCode(1);
}

#[Test]
Expand Down

0 comments on commit 255b702

Please sign in to comment.