Skip to content

Commit a39cb46

Browse files
committed
fix: skip tests when dependencies are missing
1 parent 19fb4b8 commit a39cb46

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

packages/core/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"filp/whoops": "^2.15"
1515
},
1616
"require-dev": {
17+
"tempest/validation": "dev-main",
1718
"tempest/intl": "dev-main"
1819
},
1920
"autoload": {

packages/core/src/functions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Tempest\Core\EnvironmentVariableValidationFailed;
1111
use Tempest\Core\ExceptionReporter;
1212
use Tempest\Core\Kernel;
13+
use Tempest\Intl\Translator;
1314
use Tempest\Support\Namespace\PathCouldNotBeMappedToNamespace;
1415
use Tempest\Validation\Rule;
1516
use Tempest\Validation\Validator;
@@ -77,7 +78,7 @@ function env(string $key, mixed $default = null, array $rules = []): mixed
7778
default => $value,
7879
};
7980

80-
if ($rules === []) {
81+
if ($rules === [] || ! class_exists(Validator::class) || ! class_exists(Translator::class)) {
8182
return $value;
8283
}
8384

packages/core/tests/EnvTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Tempest\Validation\Rules\IsBoolean;
1818
use Tempest\Validation\Rules\IsNotNull;
1919
use Tempest\Validation\Rules\IsNumeric;
20+
use Tempest\Validation\Validator;
2021

2122
use function Tempest\env;
2223

@@ -25,6 +26,14 @@ final class EnvTest extends TestCase
2526
#[PreCondition]
2627
protected function configure(): void
2728
{
29+
if (! class_exists(Translator::class)) {
30+
$this->markTestSkipped('`tempest/intl` is required for this test.');
31+
}
32+
33+
if (! class_exists(Validator::class)) {
34+
$this->markTestSkipped('`tempest/validation` is required for this test.');
35+
}
36+
2837
$container = new GenericContainer();
2938
$container->singleton(Translator::class, new GenericTranslator(
3039
config: new IntlConfig(currentLocale: Locale::ENGLISH, fallbackLocale: Locale::ENGLISH),

0 commit comments

Comments
 (0)