feat: skipLocally

This commit is contained in:
Nuno Maduro
2025-07-22 22:40:38 +01:00
parent f49b91ec0d
commit 924dc016cc

View File

@ -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 ([ foreach ([
'CI', 'CI',
@ -341,16 +341,33 @@ final class TestCall // @phpstan-ignore-line
'NETLIFY', 'NETLIFY',
'NOW_BUILDER', 'NOW_BUILDER',
] as $env) { ] as $env) {
if (getenv('GITHUB_ACTIONS') !== false) { if (getenv($env) !== false) {
return true;
}
}
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( return $this->skip(sprintf(
'This test is skipped on [CI].', 'This test is skipped on [CI].',
)); ));
} }
return $this;
} }
if (Environment::name() === Environment::CI) { public function skipLocally(): self
{
if ($this->runningOnCI() === false) {
return $this->skip(sprintf( return $this->skip(sprintf(
'This test is skipped on [CI].', 'This test is skipped [locally].',
)); ));
} }