1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the jquery-datatables-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 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\JQuery\DataTablesBundle\Tests\DependencyInjection\Compiler; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\DependencyInjection\Compiler\DataTablesProviderCompilerPass; |
15
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Manager\DataTablesManager; |
16
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Provider\DataTablesProviderInterface; |
17
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Tests\AbstractTestCase; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* jQuery DataTables compiler pass test. |
21
|
|
|
* |
22
|
|
|
* @author webeweb <https://github.com/webeweb> |
23
|
|
|
* @package WBW\Bundle\JQuery\DataTablesBundle\Tests\DependencyInjection\Compiler |
24
|
|
|
*/ |
25
|
|
|
class DataTablesProviderCompilerPassTest extends AbstractTestCase { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* DataTables manager. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
private $dataTablesManager; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* DataTables provider. |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
private $dataTablesProvider; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritDoc} |
43
|
|
|
*/ |
44
|
|
|
protected function setUp(): void { |
45
|
|
|
parent::setUp(); |
46
|
|
|
|
47
|
|
|
// Set a DataTables manager mock. |
48
|
|
|
$this->dataTablesManager = DataTablesManager::class; |
49
|
|
|
|
50
|
|
|
// Set a DataTables provider mock. |
51
|
|
|
$this->dataTablesProvider = DataTablesProviderInterface::class; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Test process() |
56
|
|
|
* |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
|
public function testProcess(): void { |
60
|
|
|
|
61
|
|
|
$obj = new DataTablesProviderCompilerPass(); |
62
|
|
|
|
63
|
|
|
$obj->process($this->containerBuilder); |
64
|
|
|
$this->assertFalse($this->containerBuilder->hasDefinition(DataTablesManager::SERVICE_NAME)); |
65
|
|
|
|
66
|
|
|
$this->containerBuilder->register(DataTablesManager::SERVICE_NAME, $this->dataTablesManager); |
67
|
|
|
$obj->process($this->containerBuilder); |
68
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(DataTablesManager::SERVICE_NAME)); |
69
|
|
|
$this->assertFalse($this->containerBuilder->getDefinition(DataTablesManager::SERVICE_NAME)->hasMethodCall("addProvider")); |
70
|
|
|
|
71
|
|
|
$this->containerBuilder->register("datatables.provider.test", $this->dataTablesProvider)->addTag(DataTablesProviderInterface::DATATABLES_TAG_NAME); |
72
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(DataTablesManager::SERVICE_NAME)); |
73
|
|
|
$this->assertFalse($this->containerBuilder->getDefinition(DataTablesManager::SERVICE_NAME)->hasMethodCall("addProvider")); |
74
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition("datatables.provider.test")); |
75
|
|
|
$this->assertTrue($this->containerBuilder->getDefinition("datatables.provider.test")->hasTag(DataTablesProviderInterface::DATATABLES_TAG_NAME)); |
76
|
|
|
|
77
|
|
|
$obj->process($this->containerBuilder); |
78
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition(DataTablesManager::SERVICE_NAME)); |
79
|
|
|
$this->assertTrue($this->containerBuilder->getDefinition(DataTablesManager::SERVICE_NAME)->hasMethodCall("addProvider")); |
80
|
|
|
$this->assertTrue($this->containerBuilder->hasDefinition("datatables.provider.test")); |
81
|
|
|
$this->assertTrue($this->containerBuilder->getDefinition("datatables.provider.test")->hasTag(DataTablesProviderInterface::DATATABLES_TAG_NAME)); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|