Files
pterodactyl-panel/tests/Unit/Helpers/EnvironmentWriterTraitTest.php
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

27 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace Pterodactyl\Tests\Pest\Unit\Helpers\EnvironmentWriterTraitTest;
use Pterodactyl\Tests\TestCase;
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
uses(TestCase::class);
dataset('variableDataProvider', function () {
return [['foo', 'foo'], ['abc123', 'abc123'], ['val"ue', '"val\"ue"'], ['my test value', '"my test value"'], ['mysql_p@assword', '"mysql_p@assword"'], ['mysql_p#assword', '"mysql_p#assword"'], ['mysql p@$$word', '"mysql p@$$word"'], ['mysql p%word', '"mysql p%word"'], ['mysql p#word', '"mysql p#word"'], ['abc_@#test', '"abc_@#test"'], ['test 123 $$$', '"test 123 $$$"'], ['#password%', '"#password%"'], ['$pass ', '"$pass "']];
});
test('variable is escaped properly', function ($input, $expected) {
$output = escapeEnvironmentValue($input);
expect($output)->toBe($expected);
})->with('variableDataProvider');
function escapeEnvironmentValue(string $value): string
{
$writer = new class
{
use EnvironmentWriterTrait;
};
return $writer->escapeEnvironmentValue($value);
}