|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Micro framework package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Stanislau Komar <[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 Micro\Plugin\DTO\Test\Unit; |
|
15
|
|
|
|
|
16
|
|
|
use Micro\Framework\Kernel\Configuration\DefaultApplicationConfiguration; |
|
17
|
|
|
use Micro\Plugin\DTO\DTOPluginConfiguration; |
|
18
|
|
|
use PHPUnit\Framework\TestCase; |
|
19
|
|
|
|
|
20
|
|
|
class DTOPluginConfigurationTest extends TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
public function testDefaults(): void |
|
23
|
|
|
{ |
|
24
|
|
|
$appCfg = new DefaultApplicationConfiguration([]); |
|
25
|
|
|
$pluginCfg = new DTOPluginConfiguration($appCfg); |
|
26
|
|
|
|
|
27
|
|
|
$this->assertEquals([], $pluginCfg->getSchemaPaths()); |
|
28
|
|
|
$this->assertNull($pluginCfg->getLoggerName()); |
|
29
|
|
|
$this->assertEquals('Transfer', $pluginCfg->getClassSuffix()); |
|
30
|
|
|
$this->assertEquals('src/Generated', $pluginCfg->getOutputPath()); |
|
31
|
|
|
$this->assertEquals('App\DTO\Generated', $pluginCfg->getNamespaceGeneral()); |
|
32
|
|
|
$this->assertEquals('*.transfer.xml', $pluginCfg->getSourceFileMask()); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testOverride(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$appCfg = new DefaultApplicationConfiguration([ |
|
38
|
|
|
'DTO_CLASS_NAMESPACE_GENERAL' => 'test-namespace', |
|
39
|
|
|
'DTO_CLASS_SUFFIX' => 'Test', |
|
40
|
|
|
'DTO_CLASS_SOURCE_PATH' => __DIR__, |
|
41
|
|
|
'DTO_CLASS_SOURCE_FILE_MASK' => '*.dto.xml', |
|
42
|
|
|
'DTO_GENERATED_PATH_OUTPUT' => '/app', |
|
43
|
|
|
'DTO_LOGGER_NAME' => 'default', |
|
44
|
|
|
]); |
|
45
|
|
|
|
|
46
|
|
|
$pluginCfg = new DTOPluginConfiguration($appCfg); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertEquals([__DIR__], $pluginCfg->getSchemaPaths()); |
|
49
|
|
|
$this->assertEquals('default', $pluginCfg->getLoggerName()); |
|
50
|
|
|
$this->assertEquals('Test', $pluginCfg->getClassSuffix()); |
|
51
|
|
|
$this->assertEquals('/app', $pluginCfg->getOutputPath()); |
|
52
|
|
|
$this->assertEquals('test-namespace', $pluginCfg->getNamespaceGeneral()); |
|
53
|
|
|
$this->assertEquals('*.dto.xml', $pluginCfg->getSourceFileMask()); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|