| Total Complexity | 3 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | final class ConfigTest extends TestCase |
||
| 12 | { |
||
| 13 | protected function setUp(): void |
||
| 14 | { |
||
| 15 | Config::resetInstance(); |
||
| 16 | } |
||
| 17 | |||
| 18 | public function test_get_undefined_key(): void |
||
| 19 | { |
||
| 20 | $this->expectExceptionMessageMatches('/Could not find config key "undefined-key"/'); |
||
| 21 | Config::getInstance()->get('undefined-key'); |
||
| 22 | } |
||
| 23 | |||
| 24 | public function test_get_default_value_from_undefined_key(): void |
||
| 27 | } |
||
| 28 | |||
| 29 | public function test_null_as_default_value_from_undefined_key(): void |
||
| 30 | { |
||
| 31 | self::assertNull(Config::getInstance()->get('undefined-key', null)); |
||
| 32 | } |
||
| 33 | |||
| 34 | public function test_get_using_custom_reader(): void |
||
| 35 | { |
||
| 36 | Config::getInstance()->setGlobalServices([ |
||
| 37 | 'config-readers' => [ |
||
| 38 | Config\GacelaFileConfig\GacelaConfigItem::DEFAULT_TYPE => new class () implements ConfigReaderInterface { |
||
| 39 | public function read(string $absolutePath): array |
||
| 40 | { |
||
| 41 | return ['key' => 'value']; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function canRead(string $absolutePath): bool |
||
| 53 | } |
||
| 54 | } |
||
| 55 |