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; |
13
|
|
|
|
14
|
|
|
use Throwable; |
15
|
|
|
use WBW\Bundle\CoreBundle\Config\ConfigurationHelper; |
16
|
|
|
use WBW\Bundle\CoreBundle\Provider\AssetsProviderInterface; |
17
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\DependencyInjection\WBWJQueryDataTablesExtension; |
18
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\WBWJQueryDataTablesBundle; |
19
|
|
|
use WBW\Library\Symfony\Helper\AssetsHelper; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* jQuery DataTables bundle test. |
23
|
|
|
* |
24
|
|
|
* @author webeweb <https://github.com/webeweb> |
25
|
|
|
* @package WBW\Bundle\JQuery\DataTablesBundle\Tests |
26
|
|
|
*/ |
27
|
|
|
class WBWJQueryDataTablesBundleTest extends AbstractTestCase { |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Tests build() |
31
|
|
|
* |
32
|
|
|
* @return void |
33
|
|
|
*/ |
34
|
|
|
public function testBuild(): void { |
35
|
|
|
|
36
|
|
|
$obj = new WBWJQueryDataTablesBundle(); |
37
|
|
|
|
38
|
|
|
$this->assertNull($obj->build($this->containerBuilder)); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Tests getAssetsRelativeDirectory() |
43
|
|
|
* |
44
|
|
|
* @return void |
45
|
|
|
*/ |
46
|
|
|
public function testGetAssetsRelativeDirectory(): void { |
47
|
|
|
|
48
|
|
|
$obj = new WBWJQueryDataTablesBundle(); |
49
|
|
|
|
50
|
|
|
$this->assertEquals(AssetsProviderInterface::ASSETS_RELATIVE_DIRECTORY, $obj->getAssetsRelativeDirectory()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Tests getContainerExtension() |
55
|
|
|
* |
56
|
|
|
* @return void |
57
|
|
|
*/ |
58
|
|
|
public function testGetContainerExtension(): void { |
59
|
|
|
|
60
|
|
|
$obj = new WBWJQueryDataTablesBundle(); |
61
|
|
|
|
62
|
|
|
$this->assertInstanceOf(WBWJQueryDataTablesExtension::class, $obj->getContainerExtension()); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Tests getTranslationDomain() |
67
|
|
|
* |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
public function testGetTranslationDomain(): void { |
71
|
|
|
|
72
|
|
|
$this->assertEquals(WBWJQueryDataTablesBundle::TRANSLATION_DOMAIN, WBWJQueryDataTablesBundle::getTranslationDomain()); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Tests listAssets() |
77
|
|
|
* |
78
|
|
|
* @return void |
79
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
80
|
|
|
*/ |
81
|
|
|
public function testListAssets(): void { |
82
|
|
|
|
83
|
|
|
$config = realpath(__DIR__ . "/../DependencyInjection"); |
84
|
|
|
$assets = realpath(__DIR__ . "/../Resources/assets"); |
85
|
|
|
|
86
|
|
|
// Load the YAML configuration. |
87
|
|
|
$config = ConfigurationHelper::loadYamlConfig($config, "assets"); |
88
|
|
|
$version = $config["assets"]["wbw.jquery_datatables.asset.jquery_datatables"]["version"]; |
89
|
|
|
$requires = $config["assets"]["wbw.jquery_datatables.asset.jquery_datatables"]["requires"]; |
90
|
|
|
$plugins = $config["assets"]["wbw.jquery_datatables.asset.jquery_datatables"]["plugins"]; |
91
|
|
|
|
92
|
|
|
$res = AssetsHelper::listAssets($assets); |
93
|
|
|
$this->assertCount(19, $res); |
94
|
|
|
|
95
|
|
|
$i = -1; |
96
|
|
|
|
97
|
|
|
$this->assertRegexp("/datatables\-" . preg_quote($version) . "\.zip$/", $res[++$i]); |
|
|
|
|
98
|
|
|
$this->assertRegexp("/datatables\-autofill\-" . preg_quote($plugins["autofill"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
99
|
|
|
$this->assertRegexp("/datatables\-buttons\-" . preg_quote($plugins["buttons"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
100
|
|
|
$this->assertRegexp("/datatables\-colreorder\-" . preg_quote($plugins["colreorder"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
101
|
|
|
$this->assertRegexp("/datatables\-datetime\-" . preg_quote($plugins["datetime"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
102
|
|
|
$this->assertRegexp("/datatables\-fixedcolumns\-" . preg_quote($plugins["fixedcolumns"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
103
|
|
|
$this->assertRegexp("/datatables\-fixedheader\-" . preg_quote($plugins["fixedheader"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
104
|
|
|
$this->assertRegexp("/datatables\-jszip\-" . preg_quote($requires["jszip"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
105
|
|
|
$this->assertRegexp("/datatables\-keytable\-" . preg_quote($plugins["keytable"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
106
|
|
|
$this->assertRegexp("/datatables\-pdfmake\-" . preg_quote($requires["pdfmake"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
107
|
|
|
$this->assertRegexp("/datatables\-responsive\-" . preg_quote($plugins["responsive"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
108
|
|
|
$this->assertRegexp("/datatables\-rowgroup\-" . preg_quote($plugins["rowgroup"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
109
|
|
|
$this->assertRegexp("/datatables\-rowreorder\-" . preg_quote($plugins["rowreorder"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
110
|
|
|
$this->assertRegexp("/datatables\-scroller\-" . preg_quote($plugins["scroller"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
111
|
|
|
$this->assertRegexp("/datatables\-searchbuilder\-" . preg_quote($plugins["searchbuilder"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
112
|
|
|
$this->assertRegexp("/datatables\-searchpanes\-" . preg_quote($plugins["searchpanes"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
113
|
|
|
$this->assertRegexp("/datatables\-select\-" . preg_quote($plugins["select"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
114
|
|
|
$this->assertRegexp("/datatables\-staterestore\-" . preg_quote($plugins["staterestore"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
115
|
|
|
$this->assertRegexp("/editable\-table\.zip$/", $res[++$i]); |
|
|
|
|
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Tests __construct() |
120
|
|
|
* |
121
|
|
|
* @return void |
122
|
|
|
*/ |
123
|
|
|
public function test__construct(): void { |
124
|
|
|
|
125
|
|
|
$this->assertEquals("WBWJQueryDataTablesBundle", WBWJQueryDataTablesBundle::TRANSLATION_DOMAIN); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.