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\Configuration\Helper\Test\Unit; |
15
|
|
|
|
16
|
|
|
use Micro\Framework\Kernel\Configuration\Exception\InvalidConfigurationException; |
17
|
|
|
use Micro\Kernel\App\AppKernel; |
18
|
|
|
use Micro\Plugin\Configuration\Helper\ConfigurationHelperPlugin; |
19
|
|
|
use Micro\Plugin\Configuration\Helper\Facade\ConfigurationHelperFacadeInterface; |
20
|
|
|
use PHPUnit\Framework\TestCase; |
21
|
|
|
|
22
|
|
|
class ConfigurationHelperPluginTest extends TestCase |
23
|
|
|
{ |
24
|
|
|
public function testResolvePath() |
25
|
|
|
{ |
26
|
|
|
$kernel = new AppKernel( |
27
|
|
|
[], |
28
|
|
|
[ |
29
|
|
|
ConfigurationHelperPlugin::class, |
30
|
|
|
PluginHasMethodName::class, |
31
|
|
|
], |
32
|
|
|
); |
33
|
|
|
|
34
|
|
|
$kernel->run(); |
35
|
|
|
|
36
|
|
|
/** @var ConfigurationHelperFacadeInterface $locator */ |
37
|
|
|
$locator = $kernel->container()->get(ConfigurationHelperFacadeInterface::class); |
38
|
|
|
|
39
|
|
|
$cfgHelperPath = $locator->resolvePath('@ConfigurationHelperPlugin'); |
40
|
|
|
$this->assertTrue(is_dir($cfgHelperPath)); |
41
|
|
|
|
42
|
|
|
$cfgHelperPathExists = $locator->resolvePath($cfgHelperPath); |
43
|
|
|
$this->assertEquals($cfgHelperPath, $cfgHelperPathExists); |
44
|
|
|
|
45
|
|
|
$noExists = $locator->resolvePath('NoExists'); |
46
|
|
|
$this->assertEquals('NoExists', $noExists); |
47
|
|
|
|
48
|
|
|
$namedPlugin = $locator->resolvePath('@TestPluginHasMethodName'); |
49
|
|
|
$this->assertTrue(is_dir($namedPlugin)); |
50
|
|
|
|
51
|
|
|
$this->expectException(InvalidConfigurationException::class); |
52
|
|
|
$locator->resolvePath('@NoExists'); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|