|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the dotfiles project. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Anthonius Munthi <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Dotfiles\Core\Tests\Config; |
|
15
|
|
|
|
|
16
|
|
|
use Dotfiles\Core\Config\Definition; |
|
17
|
|
|
use Dotfiles\Core\Util\Toolkit; |
|
18
|
|
|
use PHPUnit\Framework\TestCase; |
|
19
|
|
|
use Symfony\Component\Config\Definition\Processor; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class DefinitionTest. |
|
23
|
|
|
* |
|
24
|
|
|
* @covers \Dotfiles\Core\Config\Definition |
|
25
|
|
|
*/ |
|
26
|
|
|
class DefinitionTest extends TestCase |
|
27
|
|
|
{ |
|
28
|
|
|
public function getTestConfigTreeBuilderData() |
|
29
|
|
|
{ |
|
30
|
|
|
return array( |
|
31
|
|
|
array('machine_name', false), |
|
32
|
|
|
array('home_dir', getenv('HOME')), |
|
33
|
|
|
array('debug', false), |
|
34
|
|
|
array('base_dir', Toolkit::getBaseDir()), |
|
35
|
|
|
array('install_dir', '%dotfiles.home_dir%/.dotfiles'), |
|
36
|
|
|
array('log_dir', '%dotfiles.base_dir%/var/log'), |
|
37
|
|
|
array('cache_dir', '%dotfiles.base_dir%/var/cache'), |
|
38
|
|
|
array('temp_dir', sys_get_temp_dir().'/dotfiles/temp'), |
|
39
|
|
|
array('backup_dir', '%dotfiles.base_dir%/var/backup'), |
|
40
|
|
|
array('bin_dir', '%dotfiles.install_dir%/bin'), |
|
41
|
|
|
array('vendor_dir', '%dotfiles.install_dir%/vendor'), |
|
42
|
|
|
); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param string $key |
|
47
|
|
|
* @param string |
|
48
|
|
|
* @dataProvider getTestConfigTreeBuilderData |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testGetConfigTreeBuilder(string $key, string $default): void |
|
51
|
|
|
{ |
|
52
|
|
|
$definition = new Definition(); |
|
53
|
|
|
$processor = new Processor(); |
|
54
|
|
|
$config = $processor->process($definition->getConfigTreeBuilder()->buildTree(), array()); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertArrayHasKey($key, $config); |
|
57
|
|
|
$this->assertEquals($config[$key], $default); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|