-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #230 from acelaya-forks/feature/remove-laminas-config
Feature/remove laminas config
- Loading branch information
Showing
12 changed files
with
113 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ vendor/ | |
config/*.local.php | ||
data | ||
bin/rr | ||
test-resources/config/params/generated-in-test.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Installer\Util; | ||
|
||
use Webimpress\SafeWriter\FileWriter; | ||
|
||
use function sprintf; | ||
use function var_export; | ||
|
||
class ConfigWriter implements ConfigWriterInterface | ||
{ | ||
private const CONFIG_TEMPLATE = <<<TEMPLATE | ||
<?php | ||
/* Shlink config generated by shlink-installer */ | ||
return %s; | ||
TEMPLATE; | ||
|
||
|
||
public function toFile(string $fileName, array $config): void | ||
{ | ||
$content = sprintf(self::CONFIG_TEMPLATE, var_export($config, return: true)); | ||
FileWriter::writeFile($fileName, $content); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Installer\Util; | ||
|
||
interface ConfigWriterInterface | ||
{ | ||
public function toFile(string $fileName, array $config): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkioTest\Shlink\Installer\Util; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\Attributes\TestWith; | ||
use PHPUnit\Framework\TestCase; | ||
use Shlinkio\Shlink\Installer\Util\ConfigWriter; | ||
|
||
use function unlink; | ||
|
||
class ConfigWriterTest extends TestCase | ||
{ | ||
private const FILENAME = __DIR__ . '/../../test-resources/config/params/generated-in-test.php'; | ||
|
||
private ConfigWriter $configWriter; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->configWriter = new ConfigWriter(); | ||
} | ||
|
||
public static function tearDownAfterClass(): void | ||
{ | ||
unlink(self::FILENAME); | ||
} | ||
|
||
#[Test] | ||
#[TestWith([[ | ||
'foo' => 'foo', | ||
'bar' => 'bar', | ||
'baz' => 'baz', | ||
]])] | ||
#[TestWith([[ | ||
'foo' => null, | ||
'bar' => 123, | ||
'baz' => true, | ||
]])] | ||
public function configIsExportedAndWrittenToFile(array $config): void | ||
{ | ||
$this->configWriter->toFile(self::FILENAME, $config); | ||
|
||
self::assertFileExists(self::FILENAME); | ||
self::assertEquals($config, require self::FILENAME); | ||
} | ||
} |