Additional coverage to ensure values are wrapped as expected; ref #3287
This commit is contained in:
parent
38a5f2dbbf
commit
6ef60633d3
2 changed files with 58 additions and 15 deletions
43
tests/Unit/Helpers/EnvironmentWriterTraitTest.php
Normal file
43
tests/Unit/Helpers/EnvironmentWriterTraitTest.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?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);
|
||||
}
|
||||
|
||||
public function variableDataProvider(): array
|
||||
{
|
||||
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue