1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2022 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\CoreBundle\Tests\DependencyInjection\Compiler; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\CoreBundle\DependencyInjection\Compiler\StylesheetProviderCompilerPass; |
15
|
|
|
use WBW\Bundle\CoreBundle\Provider\StylesheetProvider; |
16
|
|
|
use WBW\Bundle\CoreBundle\Tests\AbstractTestCase; |
17
|
|
|
use WBW\Library\Symfony\Manager\StylesheetManager; |
18
|
|
|
use WBW\Library\Symfony\Provider\StylesheetProviderInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Stylesheet provider compiler pass test. |
22
|
|
|
* |
23
|
|
|
* @author webeweb <https://github.com/webeweb> |
24
|
|
|
* @package WBW\Bundle\CoreBundle\Tests\DependencyInjection\Compiler |
25
|
|
|
*/ |
26
|
|
|
class StylesheetProviderCompilerPassTest extends AbstractTestCase { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Stylesheet manager. |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
private $stylesheetManager; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Stylesheet provider. |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private $stylesheetProvider; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritDoc} |
44
|
|
|
*/ |
45
|
|
|
protected function setUp(): void { |
46
|
|
|
parent::setUp(); |
47
|
|
|
|
48
|
|
|
// Set a Stylesheet manager mock. |
49
|
|
|
$this->stylesheetManager = StylesheetManager::class; |
50
|
|
|
|
51
|
|
|
// Set a Stylesheet provider mock. |
52
|
|
|
$this->stylesheetProvider = StylesheetProviderInterface::class; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Test process() |
57
|
|
|
* |
58
|
|
|
* @return void |
59
|
|
|
*/ |
60
|
|
|
public function testProcess(): void { |
61
|
|
|
|
62
|
|
|
$obj = new StylesheetProviderCompilerPass(); |
63
|
|
|
|
64
|
|
|
$obj->process($this->containerBuilder); |
65
|
|
|
$this->assertFalse($this->containerBuilder->hasDefinition(StylesheetManager::SERVICE_NAME)); |
66
|
|
|
$this->assertFalse($this->containerBuilder->hasDefinition(StylesheetProvider::SERVICE_NAME)); |
67
|
|
|
|
68
|
|
|
// Register the Stylesheet manager mock. |
69
|
|
|
$this->containerBuilder->register(StylesheetManager::SERVICE_NAME, $this->stylesheetManager); |
70
|
|
|
|
71
|
|
|
$obj->process($this->containerBuilder); |
72
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(StylesheetManager::SERVICE_NAME)); |
73
|
|
|
$this->assertFalse($this->containerBuilder->hasDefinition(StylesheetProvider::SERVICE_NAME)); |
74
|
|
|
$this->assertFalse($this->containerBuilder->getDefinition(StylesheetManager::SERVICE_NAME)->hasMethodCall("addProvider")); |
75
|
|
|
|
76
|
|
|
// Register the Stylesheet provider. |
77
|
|
|
$this->containerBuilder->register(StylesheetProvider::SERVICE_NAME, $this->stylesheetProvider)->addTag(StylesheetProviderInterface::STYLESHEET_PROVIDER_TAG_NAME); |
78
|
|
|
|
79
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(StylesheetManager::SERVICE_NAME)); |
80
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(StylesheetProvider::SERVICE_NAME)); |
81
|
|
|
$this->assertFalse($this->containerBuilder->getDefinition(StylesheetManager::SERVICE_NAME)->hasMethodCall("addProvider")); |
82
|
|
|
|
83
|
|
|
$obj->process($this->containerBuilder); |
84
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(StylesheetManager::SERVICE_NAME)); |
85
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(StylesheetProvider::SERVICE_NAME)); |
86
|
|
|
$this->assertTrue($this->containerBuilder->getDefinition(StylesheetManager::SERVICE_NAME)->hasMethodCall("addProvider")); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|