Files
JobcardSystem/tests/smoke.php
T

31 lines
912 B
PHP

<?php
declare(strict_types=1);
putenv('JOBcard_TEST_VALUE=present');
require_once __DIR__ . '/../config/bootstrap.php';
$tempEnv = tempnam(sys_get_temp_dir(), 'jobcard-env-');
file_put_contents($tempEnv, "JOBcard_LOADED=\"from-file\"\n# ignored\n");
load_dotenv($tempEnv);
unlink($tempEnv);
if (getenv('JOBcard_LOADED') !== 'from-file') {
throw new RuntimeException('Expected .env values to load from file');
}
$checks = 0;
assert(env_required('JOBcard_TEST_VALUE') === 'present');
$checks++;
assert(e('<script>alert("x")</script>') === '&lt;script&gt;alert(&quot;x&quot;)&lt;/script&gt;');
$checks++;
$missingRaised = false;
try {
env_required('JOBcard_MISSING_VALUE');
} catch (RuntimeException $exception) {
$missingRaised = str_contains($exception->getMessage(), 'JOBcard_MISSING_VALUE');
}
assert($missingRaised === true);
$checks++;
printf("Foundation smoke tests: %d passed\n", $checks);