diff --git a/.gitignore b/.gitignore index 099b63d..8ee36dd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ vendor/ config/*.local.php data bin/rr +test-resources/config/params/generated-in-test.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e8204c..ce0e35b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * *Nothing* ### Removed -* *Nothing* +* Remove dependency on `laminas/laminas-config`. ### Fixed * *Nothing* diff --git a/src/Util/ConfigWriter.php b/src/Util/ConfigWriter.php index 91d8805..25ba8a1 100644 --- a/src/Util/ConfigWriter.php +++ b/src/Util/ConfigWriter.php @@ -17,6 +17,7 @@ class ConfigWriter implements ConfigWriterInterface /* Shlink config generated by shlink-installer */ return %s; + TEMPLATE; diff --git a/test/Util/ConfigWriterTest.php b/test/Util/ConfigWriterTest.php new file mode 100644 index 0000000..043084a --- /dev/null +++ b/test/Util/ConfigWriterTest.php @@ -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); + } +}