diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1cfedf..c284b80 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -91,7 +91,7 @@ jobs: SESSION_DRIVER: array TTY: true - run: vendor/bin/pest --no-parallel + run: vendor/bin/pest - name: Execute Code Sniffer via Laravel Pint run: vendor/bin/pint --test src config diff --git a/tests/Features/Commands/Hooks/BladeFormatterPreCommitHookTest.php b/tests/Features/Commands/Hooks/BladeFormatterPreCommitHookTest.php index f8e6a2d..0dde8df 100644 --- a/tests/Features/Commands/Hooks/BladeFormatterPreCommitHookTest.php +++ b/tests/Features/Commands/Hooks/BladeFormatterPreCommitHookTest.php @@ -19,6 +19,8 @@ function () { $property = $reflection->getProperty('stty'); $property->setAccessible(true); $property->setValue(true); // force stty as available + + $this->mockSymfonyStyleOnCommand(BladeFormatterPreCommitHook::class); } ); diff --git a/tests/Features/Commands/Hooks/ESLintPreCommitHookTest.php b/tests/Features/Commands/Hooks/ESLintPreCommitHookTest.php index 08e1543..177b4b2 100644 --- a/tests/Features/Commands/Hooks/ESLintPreCommitHookTest.php +++ b/tests/Features/Commands/Hooks/ESLintPreCommitHookTest.php @@ -19,6 +19,8 @@ function () { $property = $reflection->getProperty('stty'); $property->setAccessible(true); $property->setValue(true); // force stty as available + + $this->mockSymfonyStyleOnCommand(ESLintPreCommitHook::class); } ); diff --git a/tests/Features/Commands/Hooks/LarastanPreCommitHookTest.php b/tests/Features/Commands/Hooks/LarastanPreCommitHookTest.php index 4760195..5587c72 100644 --- a/tests/Features/Commands/Hooks/LarastanPreCommitHookTest.php +++ b/tests/Features/Commands/Hooks/LarastanPreCommitHookTest.php @@ -19,6 +19,8 @@ function () { $property = $reflection->getProperty('stty'); $property->setAccessible(true); $property->setValue(true); // force stty as available + + $this->mockSymfonyStyleOnCommand(LarastanPreCommitHook::class); } ); diff --git a/tests/Features/Commands/Hooks/PHPCodeSnifferPreCommitHookTest.php b/tests/Features/Commands/Hooks/PHPCodeSnifferPreCommitHookTest.php index f9ef515..520f1dc 100644 --- a/tests/Features/Commands/Hooks/PHPCodeSnifferPreCommitHookTest.php +++ b/tests/Features/Commands/Hooks/PHPCodeSnifferPreCommitHookTest.php @@ -19,6 +19,8 @@ function () { $property = $reflection->getProperty('stty'); $property->setAccessible(true); $property->setValue(true); // force stty as available + + $this->mockSymfonyStyleOnCommand(PHPCodeSnifferPreCommitHook::class); } ); diff --git a/tests/Features/Commands/Hooks/PhpInsightsPreCommitHookTest.php b/tests/Features/Commands/Hooks/PhpInsightsPreCommitHookTest.php index b54d969..2a193c4 100644 --- a/tests/Features/Commands/Hooks/PhpInsightsPreCommitHookTest.php +++ b/tests/Features/Commands/Hooks/PhpInsightsPreCommitHookTest.php @@ -19,6 +19,8 @@ function () { $property = $reflection->getProperty('stty'); $property->setAccessible(true); $property->setValue(true); // force stty as available + + $this->mockSymfonyStyleOnCommand(PhpInsightsPreCommitHook::class); } ); diff --git a/tests/Features/Commands/Hooks/PintPreCommitHookTest.php b/tests/Features/Commands/Hooks/PintPreCommitHookTest.php index 180048a..f324f33 100644 --- a/tests/Features/Commands/Hooks/PintPreCommitHookTest.php +++ b/tests/Features/Commands/Hooks/PintPreCommitHookTest.php @@ -19,6 +19,8 @@ function () { $property = $reflection->getProperty('stty'); $property->setAccessible(true); $property->setValue(true); // force stty as available + + $this->mockSymfonyStyleOnCommand(PintPreCommitHook::class); } ); diff --git a/tests/Features/Commands/Hooks/PrettierPreCommitHookTest.php b/tests/Features/Commands/Hooks/PrettierPreCommitHookTest.php index d47ed46..e996213 100644 --- a/tests/Features/Commands/Hooks/PrettierPreCommitHookTest.php +++ b/tests/Features/Commands/Hooks/PrettierPreCommitHookTest.php @@ -19,6 +19,8 @@ function () { $property = $reflection->getProperty('stty'); $property->setAccessible(true); $property->setValue(true); // force stty as available + + $this->mockSymfonyStyleOnCommand(PrettierPreCommitHook::class); } ); diff --git a/tests/Features/Commands/Hooks/RectorPreCommitHookTest.php b/tests/Features/Commands/Hooks/RectorPreCommitHookTest.php index fcbeaf5..71aa167 100644 --- a/tests/Features/Commands/Hooks/RectorPreCommitHookTest.php +++ b/tests/Features/Commands/Hooks/RectorPreCommitHookTest.php @@ -19,6 +19,8 @@ function () { $property = $reflection->getProperty('stty'); $property->setAccessible(true); $property->setValue(true); + + $this->mockSymfonyStyleOnCommand(RectorPreCommitHook::class); } ); diff --git a/tests/TestCase.php b/tests/TestCase.php index 32c162d..6a682a0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,6 +6,7 @@ use Igorsgm\GitHooks\Facades\GitHooks; use Igorsgm\GitHooks\GitHooksServiceProvider; use Igorsgm\GitHooks\Tests\Traits\WithTmpFiles; +use Mockery; class TestCase extends \Orchestra\Testbench\TestCase { @@ -110,4 +111,19 @@ public function initializeGitAsTempDirectory(): void $this->gitInit() ->initializeTempDirectory(base_path('.git')); } + + protected function mockSymfonyStyleOnCommand(string $commandClass, bool $confirmDefault = true): void + { + $this->app->extend($commandClass, function ($command) use ($confirmDefault) { + $style = Mockery::mock(\Symfony\Component\Console\Style\SymfonyStyle::class) + ->makePartial() + ->shouldAllowMockingProtectedMethods(); + + $style->shouldReceive('confirm')->andReturn($confirmDefault); + + $command->io = $style; + + return $command; + }); + } }