mirror of
https://github.com/coollabsio/coolify.git
synced 2026-10-28 17:44:36 +08:00
35 lines
1.4 KiB
PHP
35 lines
1.4 KiB
PHP
<?php
|
|
|
|
test('escapeComposeEnvFileValue wraps simple values in double quotes', function () {
|
|
expect(escapeComposeEnvFileValue('runtime-only-value'))->toBe('"runtime-only-value"');
|
|
});
|
|
|
|
test('escapeComposeEnvFileValue keeps mixed quotes and dollars literal when interpolation is off', function () {
|
|
$value = 'hello world; quotes" \'$`';
|
|
|
|
$escaped = escapeComposeEnvFileValue($value, allowInterpolation: false);
|
|
|
|
expect($escaped)->toBe('"hello world; quotes\\" \'\\$`"');
|
|
});
|
|
|
|
test('escapeComposeEnvFileValue blocks command substitution when interpolation is off', function () {
|
|
$escaped = escapeComposeEnvFileValue('$(touch /tmp/should-not-exist)', allowInterpolation: false);
|
|
|
|
expect($escaped)->toBe('"\\$(touch /tmp/should-not-exist)"');
|
|
});
|
|
|
|
test('escapeComposeEnvFileValue leaves $VAR intact when interpolation is on', function () {
|
|
expect(escapeComposeEnvFileValue('$BOTH_PHASES', allowInterpolation: true))->toBe('"$BOTH_PHASES"');
|
|
});
|
|
|
|
test('escapeComposeEnvFileValue preserves multiline literals', function () {
|
|
$escaped = escapeComposeEnvFileValue("line one\nline two", allowInterpolation: false);
|
|
|
|
expect($escaped)->toBe("\"line one\nline two\"");
|
|
});
|
|
|
|
test('escapeComposeEnvFileValue escapes backslashes and double quotes', function () {
|
|
expect(escapeComposeEnvFileValue('C:\\path\\"quoted"'))
|
|
->toBe('"C:\\\\path\\\\\\"quoted\\""');
|
|
});
|