1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-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\CoreBundle\Tests; |
13
|
|
|
|
14
|
|
|
use Throwable; |
15
|
|
|
use WBW\Bundle\CoreBundle\Config\ConfigurationHelper; |
16
|
|
|
use WBW\Bundle\CoreBundle\DependencyInjection\WBWCoreExtension; |
17
|
|
|
use WBW\Bundle\CoreBundle\Provider\AssetsProviderInterface; |
18
|
|
|
use WBW\Bundle\CoreBundle\WBWCoreBundle; |
19
|
|
|
use WBW\Library\Symfony\Helper\AssetsHelper; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Core bundle test. |
23
|
|
|
* |
24
|
|
|
* @author webeweb <https://github.com/webeweb> |
25
|
|
|
* @package WBW\Bundle\CoreBundle\Tests |
26
|
|
|
*/ |
27
|
|
|
class WBWCoreBundleTest extends AbstractTestCase { |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Tests build() |
31
|
|
|
* |
32
|
|
|
* @return void |
33
|
|
|
*/ |
34
|
|
|
public function testBuild(): void { |
35
|
|
|
|
36
|
|
|
$obj = new WBWCoreBundle(); |
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 WBWCoreBundle(); |
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 WBWCoreBundle(); |
61
|
|
|
|
62
|
|
|
$this->assertInstanceOf(WBWCoreExtension::class, $obj->getContainerExtension()); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Tests getTranslationDomain() |
67
|
|
|
* |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
public function testGetTranslationDomain(): void { |
71
|
|
|
|
72
|
|
|
$this->assertEquals(WBWCoreBundle::TRANSLATION_DOMAIN, WBWCoreBundle::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
|
|
|
$plugins = $config["assets"]["wbw.core.asset.core"]["plugins"]; |
89
|
|
|
|
90
|
|
|
$res = AssetsHelper::listAssets($assets); |
91
|
|
|
$this->assertCount(27, $res); |
92
|
|
|
|
93
|
|
|
$i = -1; |
94
|
|
|
|
95
|
|
|
$this->assertRegExp("/animate\.css-" . preg_quote($plugins["animate_css"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
96
|
|
|
$this->assertRegExp("/chart.js-" . preg_quote($plugins["chart_js"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
97
|
|
|
$this->assertRegExp("/clippy\.js\.zip$/", $res[++$i]); |
|
|
|
|
98
|
|
|
$this->assertRegExp("/fontawesome-" . preg_quote($plugins["font_awesome"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
99
|
|
|
$this->assertRegExp("/fontawesome-6\.2\.0\.zip$/", $res[++$i]); |
|
|
|
|
100
|
|
|
$this->assertRegExp("/fullcalendar-" . preg_quote($plugins["full_calendar"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
101
|
|
|
$this->assertRegExp("/jquery-" . preg_quote($plugins["jquery"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
102
|
|
|
$this->assertRegExp("/jquery-contextmenu-" . preg_quote($plugins["jquery_context_menu"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
103
|
|
|
$this->assertRegExp("/jquery-easyautocomplete-" . preg_quote($plugins["jquery_easy_autocomplete"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
104
|
|
|
$this->assertRegExp("/jquery-fancybox-" . preg_quote($plugins["jquery_fancy_box"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
105
|
|
|
$this->assertRegExp("/jquery-inputmask-" . preg_quote($plugins["jquery_input_mask"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
106
|
|
|
$this->assertRegExp("/jquery-select2-" . preg_quote($plugins["jquery_select2"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
107
|
|
|
$this->assertRegExp("/leaflet-" . preg_quote($plugins["leaflet"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
108
|
|
|
$this->assertRegExp("/leaflet-color-markers-" . preg_quote($plugins["leaflet_color_markers"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
109
|
|
|
$this->assertRegExp("/leaflet-markercluster-" . preg_quote($plugins["leaflet_marker_cluster"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
110
|
|
|
$this->assertRegExp("/lightgallery-" . preg_quote($plugins["light_gallery"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
111
|
|
|
$this->assertRegExp("/material-design-color-palette-" . preg_quote($plugins["material_design_color_palette"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
112
|
|
|
$this->assertRegExp("/material-design-hierarchical-display-" . preg_quote($plugins["material_design_hierarchical_display"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
113
|
|
|
$this->assertRegExp("/material-design-iconic-font-" . preg_quote($plugins["material_design_iconic_font"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
114
|
|
|
$this->assertRegExp("/meteocons\.zip$/", $res[++$i]); |
|
|
|
|
115
|
|
|
$this->assertRegExp("/simplemde-markdown-editor-" . preg_quote($plugins["simplemde_markdown_editor"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
116
|
|
|
$this->assertRegExp("/sweetalert-" . preg_quote($plugins["sweet_alert"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
117
|
|
|
$this->assertRegExp("/sweetalert2-" . preg_quote($plugins["sweet_alert2"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
118
|
|
|
$this->assertRegExp("/syntaxhighlighter-" . preg_quote($plugins["syntax_highlighter"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
119
|
|
|
$this->assertRegExp("/twemoji-" . preg_quote($plugins["twemoji"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
120
|
|
|
$this->assertRegExp("/typed\.js-" . preg_quote($plugins["typed_js"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
121
|
|
|
$this->assertRegExp("/waitme-" . preg_quote($plugins["wait_me"]["version"]) . "\.zip$/", $res[++$i]); |
|
|
|
|
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Tests __construct() |
126
|
|
|
* |
127
|
|
|
* @return void |
128
|
|
|
*/ |
129
|
|
|
public function test__construct(): void { |
130
|
|
|
|
131
|
|
|
$this->assertEquals("WBWCoreBundle", WBWCoreBundle::TRANSLATION_DOMAIN); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
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.