From 924dc016cca437f83a4601573ba305a7496c9e78 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 22 Jul 2025 22:40:38 +0100 Subject: [PATCH] feat: `skipLocally` --- src/PendingCalls/TestCall.php | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 55a948e4..c86e5d7e 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -316,9 +316,9 @@ final class TestCall // @phpstan-ignore-line } /** - * Skips the current test when running on a CI environments. + * Weather the current test is running on a CI environment. */ - public function skipOnCI(): self + private function runningOnCI(): bool { foreach ([ 'CI', @@ -341,14 +341,20 @@ final class TestCall // @phpstan-ignore-line 'NETLIFY', 'NOW_BUILDER', ] as $env) { - if (getenv('GITHUB_ACTIONS') !== false) { - return $this->skip(sprintf( - 'This test is skipped on [CI].', - )); + if (getenv($env) !== false) { + return true; } } - if (Environment::name() === Environment::CI) { + return Environment::name() === Environment::CI; + } + + /** + * Skips the current test when running on a CI environments. + */ + public function skipOnCI(): self + { + if ($this->runningOnCI()) { return $this->skip(sprintf( 'This test is skipped on [CI].', )); @@ -357,6 +363,17 @@ final class TestCall // @phpstan-ignore-line return $this; } + public function skipLocally(): self + { + if ($this->runningOnCI() === false) { + return $this->skip(sprintf( + 'This test is skipped [locally].', + )); + } + + return $this; + } + /** * Skips the current test unless the given test is running on Windows. */