Skip to content

Commit

Permalink
Complete InteractsWithConsole test coverage
Browse files Browse the repository at this point in the history
Add a small test to get 100% coverage
  • Loading branch information
smnandre committed Jan 1, 2025
1 parent a3a7e4a commit e3baf73
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/UnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Console\Helper\OutputWrapper;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\HttpKernel\Kernel;
use Zenstruck\Console\Test\InteractsWithConsole;
use Zenstruck\Console\Test\TestCommand;
use Zenstruck\Console\Test\Tests\Fixture\FixtureCommand;

Expand Down Expand Up @@ -297,4 +298,27 @@ public function configure(): void
->complete('kevin --message=g')->is(['hello', 'hi', 'greetings'])->back()
;
}

/**
* @test
*/
public function trait_throws_when_not_in_kernel_test_case(): void
{
$testClass = new class {
use InteractsWithConsole;

/**
* @test
*/
public function test(): void
{
$this->consoleCommand('my:command');
}
};

$this->expectException(\LogicException::class);
$this->expectExceptionMessage('The Zenstruck\Console\Test\InteractsWithConsole trait can only be used with Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.');

(new $testClass())->test();
}
}

0 comments on commit e3baf73

Please sign in to comment.