add get file load type test

This commit is contained in:
sunxyw
2022-08-21 16:13:16 +08:00
parent 07b2f175f3
commit 74af1516ac
3 changed files with 43 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ namespace Tests\ZM\Config;
use PHPUnit\Framework\TestCase;
use ZM\Config\RefactoredConfig;
use ZM\Utils\ReflectionUtil;
/**
* @internal
@@ -87,6 +88,7 @@ class RefactoredConfigTest extends TestCase
/**
* @dataProvider providerTestGetValue
* @param mixed $expected
*/
public function testGetValue(string $key, $expected): void
{
@@ -127,4 +129,25 @@ class RefactoredConfigTest extends TestCase
$this->assertSame('environment', self::$config->get('test.from'));
$this->assertSame('development', self::$config->get('test.env'));
}
/**
* @dataProvider providerTestGetFileLoadType
*/
public function testGetFileLoadType(string $name, string $type): void
{
$method = ReflectionUtil::getMethod(RefactoredConfig::class, 'getFileLoadType');
$actual = $method->invokeArgs(self::$config, [$name]);
$this->assertSame($type, $actual);
}
public function providerTestGetFileLoadType(): array
{
return [
'global' => ['test', 'global'],
'environment' => ['test.development', 'environment'],
'undefined' => ['test.dev.inv', 'undefined'],
'patch' => ['test.patch', 'patch'],
// 'complex' => ['test.patch.development', 'patch'],
];
}
}