pelican-panel-mirror/tests/Unit/Helpers/EnvironmentWriterTraitTest.php
Lance Pioch f8ad9a1805
Use PestPHP (#962)
* Install Pest

* Don’t use bootstrap file anymore

* Fix comment

* Think this is needed

* Reset this

* Switch dataproviders to attributes

* Fix these

* Support in memory databases

* Fix this migration

* Switch this back for now

* Add missing import

* Truncate and reseed database

* These are replaced now

* Switch ci to use pest
2025-01-30 16:39:17 -05:00

44 lines
1.2 KiB
PHP

<?php
namespace App\Tests\Unit\Helpers;
use App\Tests\TestCase;
use App\Traits\EnvironmentWriterTrait;
use PHPUnit\Framework\Attributes\DataProvider;
class EnvironmentWriterTraitTest extends TestCase
{
#[DataProvider('variableDataProvider')]
public function testVariableIsEscapedProperly($input, $expected): void
{
$output = (new FooClass())->escapeEnvironmentValue($input);
$this->assertSame($expected, $output);
}
public static function variableDataProvider(): array
{
return [
['foo', 'foo'],
['abc123', 'abc123'],
['val"ue', '"val\"ue"'],
['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;
}