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; |
13
|
|
|
|
14
|
|
|
use Throwable; |
15
|
|
|
use WBW\Bundle\CoreBundle\Twig\Extension\AssetsTwigExtension; |
16
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Command\ListDataTablesProviderCommand; |
17
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Controller\DataTablesController; |
18
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\DependencyInjection\Configuration; |
19
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\DependencyInjection\WBWJQueryDataTablesExtension; |
20
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Manager\DataTablesManager; |
21
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Tests\AbstractTestCase; |
22
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Twig\Extension\DataTablesTwigExtension; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* DataTables extension test. |
26
|
|
|
* |
27
|
|
|
* @author webeweb <https://github.com/webeweb> |
28
|
|
|
* @package WBW\Bundle\JQuery\DataTablesBundle\Tests\DependencyInjection |
29
|
|
|
*/ |
30
|
|
|
class WBWJQueryDataTablesExtensionTest extends AbstractTestCase { |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Configs. |
34
|
|
|
* |
35
|
|
|
* @var array<string,mixed> |
36
|
|
|
*/ |
37
|
|
|
private $configs; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritDoc} |
41
|
|
|
*/ |
42
|
|
|
protected function setUp(): void { |
43
|
|
|
parent::setUp(); |
44
|
|
|
|
45
|
|
|
// Set a Bootstrap renderer Twig extension mock |
46
|
|
|
$this->containerBuilder->set(AssetsTwigExtension::SERVICE_NAME, new AssetsTwigExtension($this->twigEnvironment)); |
47
|
|
|
|
48
|
|
|
// Set a configs array mock. |
49
|
|
|
$this->configs = [ |
50
|
|
|
WBWJQueryDataTablesExtension::EXTENSION_ALIAS => [], |
51
|
|
|
]; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Test getAlias() |
56
|
|
|
* |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
|
public function testGetAlias(): void { |
60
|
|
|
|
61
|
|
|
$obj = new WBWJQueryDataTablesExtension(); |
62
|
|
|
|
63
|
|
|
$this->assertEquals(WBWJQueryDataTablesExtension::EXTENSION_ALIAS, $obj->getAlias()); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Test getConfiguration() |
68
|
|
|
* |
69
|
|
|
* @return void |
70
|
|
|
*/ |
71
|
|
|
public function testGetConfiguration(): void { |
72
|
|
|
|
73
|
|
|
$obj = new WBWJQueryDataTablesExtension(); |
74
|
|
|
|
75
|
|
|
$this->assertInstanceOf(Configuration::class, $obj->getConfiguration([], $this->containerBuilder)); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Test load() |
80
|
|
|
* |
81
|
|
|
* @return void |
82
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
83
|
|
|
*/ |
84
|
|
|
public function testLoad(): void { |
85
|
|
|
|
86
|
|
|
$obj = new WBWJQueryDataTablesExtension(); |
87
|
|
|
|
88
|
|
|
$obj->load($this->configs, $this->containerBuilder); |
89
|
|
|
|
90
|
|
|
// Commands |
91
|
|
|
$this->assertInstanceOf(ListDataTablesProviderCommand::class, $this->containerBuilder->get(ListDataTablesProviderCommand::SERVICE_NAME)); |
92
|
|
|
|
93
|
|
|
// Controllers |
94
|
|
|
$this->assertInstanceOf(DataTablesController::class, $this->containerBuilder->get(DataTablesController::SERVICE_NAME)); |
95
|
|
|
|
96
|
|
|
// Managers |
97
|
|
|
$this->assertInstanceOf(DataTablesManager::class, $this->containerBuilder->get(DataTablesManager::SERVICE_NAME)); |
98
|
|
|
|
99
|
|
|
// Twig extensions. |
100
|
|
|
$this->assertInstanceOf(DataTablesTwigExtension::class, $this->containerBuilder->get(DataTablesTwigExtension::SERVICE_NAME)); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Test __construct() |
105
|
|
|
* |
106
|
|
|
* @return void |
107
|
|
|
*/ |
108
|
|
|
public function test__construct(): void { |
109
|
|
|
|
110
|
|
|
$this->assertEquals("wbw_jquery_datatables", WBWJQueryDataTablesExtension::EXTENSION_ALIAS); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|