2021-04-24 23:39:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Tests\Unit\Helpers;
|
|
|
|
|
|
|
|
use Pterodactyl\Tests\TestCase;
|
|
|
|
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
|
|
|
|
|
|
|
|
class EnvironmentWriterTraitTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider variableDataProvider
|
|
|
|
*/
|
|
|
|
public function testVariableIsEscapedProperly($input, $expected)
|
|
|
|
{
|
|
|
|
$output = (new FooClass())->escapeEnvironmentValue($input);
|
|
|
|
|
|
|
|
$this->assertSame($expected, $output);
|
|
|
|
}
|
|
|
|
|
2023-02-23 19:30:16 +00:00
|
|
|
public static function variableDataProvider(): array
|
2021-04-24 23:39:56 +00:00
|
|
|
{
|
|
|
|
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 "'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class FooClass
|
|
|
|
{
|
|
|
|
use EnvironmentWriterTrait;
|
|
|
|
}
|