1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2019 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\QuoteProviderCompilerPass; |
15
|
|
|
use WBW\Bundle\CoreBundle\Tests\AbstractTestCase; |
16
|
|
|
use WBW\Library\Symfony\Manager\QuoteManager; |
17
|
|
|
use WBW\Library\Symfony\Provider\QuoteProviderInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Quote provider compiler pass test. |
21
|
|
|
* |
22
|
|
|
* @author webeweb <https://github.com/webeweb> |
23
|
|
|
* @package WBW\Bundle\CoreBundle\Tests\DependencyInjection\Compiler |
24
|
|
|
*/ |
25
|
|
|
class QuoteProviderCompilerPassTest extends AbstractTestCase { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Quote manager. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
private $quoteManager; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Quote provider. |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
private $quoteProvider; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritDoc} |
43
|
|
|
*/ |
44
|
|
|
protected function setUp(): void { |
45
|
|
|
parent::setUp(); |
46
|
|
|
|
47
|
|
|
// Set a Quote manager mock. |
48
|
|
|
$this->quoteManager = QuoteManager::class; |
49
|
|
|
|
50
|
|
|
// Set a Quote provider mock. |
51
|
|
|
$this->quoteProvider = QuoteProviderInterface::class; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Test process() |
56
|
|
|
* |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
|
public function testProcess(): void { |
60
|
|
|
|
61
|
|
|
// Set a Service name mock. |
62
|
|
|
$serviceName = "wbw.core.provider.quote"; |
63
|
|
|
|
64
|
|
|
$obj = new QuoteProviderCompilerPass(); |
65
|
|
|
|
66
|
|
|
$obj->process($this->containerBuilder); |
67
|
|
|
$this->assertFalse($this->containerBuilder->hasDefinition(QuoteManager::SERVICE_NAME)); |
68
|
|
|
|
69
|
|
|
// Register the Quote manager mock. |
70
|
|
|
$this->containerBuilder->register(QuoteManager::SERVICE_NAME, $this->quoteManager); |
71
|
|
|
|
72
|
|
|
$obj->process($this->containerBuilder); |
73
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(QuoteManager::SERVICE_NAME)); |
74
|
|
|
$this->assertFalse($this->containerBuilder->hasDefinition($serviceName)); |
75
|
|
|
$this->assertFalse($this->containerBuilder->getDefinition(QuoteManager::SERVICE_NAME)->hasMethodCall("addProvider")); |
76
|
|
|
|
77
|
|
|
// Register the Quote provider. |
78
|
|
|
$this->containerBuilder->register($serviceName, $this->quoteProvider)->addTag(QuoteProviderInterface::QUOTE_PROVIDER_TAG_NAME); |
79
|
|
|
|
80
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(QuoteManager::SERVICE_NAME)); |
81
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition($serviceName)); |
82
|
|
|
$this->assertFalse($this->containerBuilder->getDefinition(QuoteManager::SERVICE_NAME)->hasMethodCall("addProvider")); |
83
|
|
|
|
84
|
|
|
$obj->process($this->containerBuilder); |
85
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(QuoteManager::SERVICE_NAME)); |
86
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition($serviceName)); |
87
|
|
|
$this->assertTrue($this->containerBuilder->getDefinition(QuoteManager::SERVICE_NAME)->hasMethodCall("addProvider")); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|