|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace terabytesoft\assets\fontawesome\tests; |
|
4
|
|
|
|
|
5
|
|
|
use terabytesoft\assets\FontAwesome\tests\UnitTester; |
|
6
|
|
|
use terabytesoft\assets\fontawesome\dev\js\NpmAllAsset; |
|
7
|
|
|
use terabytesoft\assets\fontawesome\dev\js\NpmBrandAsset; |
|
8
|
|
|
use terabytesoft\assets\fontawesome\dev\js\NpmFontAwesomeAsset; |
|
9
|
|
|
use terabytesoft\assets\fontawesome\dev\js\NpmRegularAsset; |
|
10
|
|
|
use terabytesoft\assets\fontawesome\dev\js\NpmSolidAsset; |
|
11
|
|
|
use yii\web\AssetBundle; |
|
12
|
|
|
use yii\web\View; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class DevJsCest |
|
16
|
|
|
* |
|
17
|
|
|
* Unit tests for codeception dev fontawesome js |
|
18
|
|
|
*/ |
|
19
|
|
|
class DevJsCest |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var \yii\web\View; |
|
23
|
|
|
*/ |
|
24
|
|
|
private $view; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* _before |
|
28
|
|
|
* |
|
29
|
|
|
* @param UnitTester $I |
|
30
|
|
|
*/ |
|
31
|
|
|
public function _before(UnitTester $I): void |
|
32
|
|
|
{ |
|
33
|
|
|
$this->view = new View(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* _after |
|
38
|
|
|
* |
|
39
|
|
|
* @param UnitTester $I |
|
40
|
|
|
*/ |
|
41
|
|
|
public function _after(UnitTester $I): void |
|
42
|
|
|
{ |
|
43
|
|
|
unset($this->view); |
|
44
|
|
|
$I->clearDirectory(\Yii::getAlias('@public/assets')); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* testNpmAllAssetRegister |
|
49
|
|
|
* |
|
50
|
|
|
* @param UnitTester $I |
|
51
|
|
|
*/ |
|
52
|
|
|
public function testNpmAllAssetRegister(UnitTester $I): void |
|
53
|
|
|
{ |
|
54
|
|
|
$I->assertEmpty($this->view->assetBundles); |
|
55
|
|
|
|
|
56
|
|
|
NpmAllAsset::register($this->view); |
|
57
|
|
|
|
|
58
|
|
|
$I->assertCount(2, $this->view->assetBundles); |
|
59
|
|
|
|
|
60
|
|
|
$I->assertArrayHasKey(NpmAllAsset::class, $this->view->assetBundles); |
|
61
|
|
|
$I->assertArrayHasKey(NpmFontAwesomeAsset::class, $this->view->assetBundles); |
|
62
|
|
|
|
|
63
|
|
|
$result = $this->view->renderFile(codecept_data_dir() . 'main.php'); |
|
64
|
|
|
|
|
65
|
|
|
$I->assertRegexp('/all.js/', $result); |
|
66
|
|
|
$I->assertRegexp('/fontawesome.js/', $result); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* testNpmBrandAssetRegister |
|
71
|
|
|
* |
|
72
|
|
|
* @param UnitTester $I |
|
73
|
|
|
*/ |
|
74
|
|
|
public function testNpmBrandAssetRegister(UnitTester $I): void |
|
75
|
|
|
{ |
|
76
|
|
|
$I->assertEmpty($this->view->assetBundles); |
|
77
|
|
|
|
|
78
|
|
|
NpmBrandAsset::register($this->view); |
|
79
|
|
|
|
|
80
|
|
|
$I->assertCount(2, $this->view->assetBundles); |
|
81
|
|
|
|
|
82
|
|
|
$I->assertArrayHasKey(NpmBrandAsset::class, $this->view->assetBundles); |
|
83
|
|
|
$I->assertArrayHasKey(NpmFontAwesomeAsset::class, $this->view->assetBundles); |
|
84
|
|
|
|
|
85
|
|
|
$result = $this->view->renderFile(codecept_data_dir() . 'main.php'); |
|
86
|
|
|
|
|
87
|
|
|
$I->assertRegexp('/brands.js/', $result); |
|
88
|
|
|
$I->assertRegexp('/fontawesome.js/', $result); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* testNpmFontAwesomeAssetRegister |
|
93
|
|
|
* |
|
94
|
|
|
* @param UnitTester $I |
|
95
|
|
|
*/ |
|
96
|
|
|
public function testNpmFontAwesomeAssetRegister(UnitTester $I): void |
|
97
|
|
|
{ |
|
98
|
|
|
$I->assertEmpty($this->view->assetBundles); |
|
99
|
|
|
|
|
100
|
|
|
NpmFontAwesomeAsset::register($this->view); |
|
101
|
|
|
|
|
102
|
|
|
$I->assertCount(1, $this->view->assetBundles); |
|
103
|
|
|
|
|
104
|
|
|
$I->assertArrayHasKey(NpmFontAwesomeAsset::class, $this->view->assetBundles); |
|
105
|
|
|
|
|
106
|
|
|
$result = $this->view->renderFile(codecept_data_dir() . 'main.php'); |
|
107
|
|
|
|
|
108
|
|
|
$I->assertRegexp('/fontawesome.js/', $result); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* testNpmRegularAssetRegister |
|
113
|
|
|
* |
|
114
|
|
|
* @param UnitTester $I |
|
115
|
|
|
*/ |
|
116
|
|
|
public function testNpmRegularAssetRegister(UnitTester $I): void |
|
117
|
|
|
{ |
|
118
|
|
|
$I->assertEmpty($this->view->assetBundles); |
|
119
|
|
|
|
|
120
|
|
|
NpmRegularAsset::register($this->view); |
|
121
|
|
|
|
|
122
|
|
|
$I->assertCount(2, $this->view->assetBundles); |
|
123
|
|
|
|
|
124
|
|
|
$I->assertArrayHasKey(NpmRegularAsset::class, $this->view->assetBundles); |
|
125
|
|
|
$I->assertArrayHasKey(NpmFontAwesomeAsset::class, $this->view->assetBundles); |
|
126
|
|
|
|
|
127
|
|
|
$result = $this->view->renderFile(codecept_data_dir() . 'main.php'); |
|
128
|
|
|
|
|
129
|
|
|
$I->assertRegexp('/regular.js/', $result); |
|
130
|
|
|
$I->assertRegexp('/fontawesome.js/', $result); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* testNpmSolidAssetRegister |
|
135
|
|
|
* |
|
136
|
|
|
* @param UnitTester $I |
|
137
|
|
|
*/ |
|
138
|
|
|
public function testNpmSolidAssetRegister(UnitTester $I): void |
|
139
|
|
|
{ |
|
140
|
|
|
$I->assertEmpty($this->view->assetBundles); |
|
141
|
|
|
|
|
142
|
|
|
NpmSolidAsset::register($this->view); |
|
143
|
|
|
|
|
144
|
|
|
$I->assertCount(2, $this->view->assetBundles); |
|
145
|
|
|
|
|
146
|
|
|
$I->assertArrayHasKey(NpmSolidAsset::class, $this->view->assetBundles); |
|
147
|
|
|
$I->assertArrayHasKey(NpmFontAwesomeAsset::class, $this->view->assetBundles); |
|
148
|
|
|
|
|
149
|
|
|
$result = $this->view->renderFile(codecept_data_dir() . 'main.php'); |
|
150
|
|
|
|
|
151
|
|
|
$I->assertRegexp('/solid.js/', $result); |
|
152
|
|
|
$I->assertRegexp('/fontawesome.js/', $result); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* testNpmAllAssetSimpleDependency |
|
157
|
|
|
* |
|
158
|
|
|
* @param UnitTester $I |
|
159
|
|
|
*/ |
|
160
|
|
|
public function testNpmAllAssetSimpleDependency(UnitTester $I): void |
|
161
|
|
|
{ |
|
162
|
|
|
$I->assertEmpty($this->view->assetBundles); |
|
163
|
|
|
|
|
164
|
|
|
NpmAllAsset::register($this->view); |
|
165
|
|
|
|
|
166
|
|
|
$I->assertCount(2, $this->view->assetBundles); |
|
167
|
|
|
|
|
168
|
|
|
$I->assertArrayHasKey(NpmAllAsset::class, $this->view->assetBundles); |
|
169
|
|
|
$I->assertArrayHasKey(NpmFontAwesomeAsset::class, $this->view->assetBundles); |
|
170
|
|
|
|
|
171
|
|
|
$I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[NpmAllAsset::class]); |
|
172
|
|
|
$I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[NpmFontAwesomeAsset::class]); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* testNpmBrandAssetSimpleDependency |
|
177
|
|
|
* |
|
178
|
|
|
* @param UnitTester $I |
|
179
|
|
|
*/ |
|
180
|
|
|
public function testNpmBrandAssetSimpleDependency(UnitTester $I): void |
|
181
|
|
|
{ |
|
182
|
|
|
$I->assertEmpty($this->view->assetBundles); |
|
183
|
|
|
|
|
184
|
|
|
NpmBrandAsset::register($this->view); |
|
185
|
|
|
|
|
186
|
|
|
$I->assertCount(2, $this->view->assetBundles); |
|
187
|
|
|
|
|
188
|
|
|
$I->assertArrayHasKey(NpmBrandAsset::class, $this->view->assetBundles); |
|
189
|
|
|
$I->assertArrayHasKey(NpmFontAwesomeAsset::class, $this->view->assetBundles); |
|
190
|
|
|
|
|
191
|
|
|
$I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[NpmBrandAsset::class]); |
|
192
|
|
|
$I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[NpmFontAwesomeAsset::class]); |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* testNpmFontAwesomeAssetSimpleDependency |
|
197
|
|
|
* |
|
198
|
|
|
* @param UnitTester $I |
|
199
|
|
|
*/ |
|
200
|
|
|
public function testNpmFontAwesomeAssetSimpleDependency(UnitTester $I): void |
|
201
|
|
|
{ |
|
202
|
|
|
$I->assertEmpty($this->view->assetBundles); |
|
203
|
|
|
|
|
204
|
|
|
NpmFontAwesomeAsset::register($this->view); |
|
205
|
|
|
|
|
206
|
|
|
$I->assertCount(1, $this->view->assetBundles); |
|
207
|
|
|
|
|
208
|
|
|
$I->assertArrayHasKey(NpmFontAwesomeAsset::class, $this->view->assetBundles); |
|
209
|
|
|
|
|
210
|
|
|
$I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[NpmFontAwesomeAsset::class]); |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
/** |
|
214
|
|
|
* testNpmRegularAssetSimpleDependency |
|
215
|
|
|
* |
|
216
|
|
|
* @param UnitTester $I |
|
217
|
|
|
*/ |
|
218
|
|
|
public function testNpmRegularAssetSimpleDependency(UnitTester $I): void |
|
219
|
|
|
{ |
|
220
|
|
|
$I->assertEmpty($this->view->assetBundles); |
|
221
|
|
|
|
|
222
|
|
|
NpmRegularAsset::register($this->view); |
|
223
|
|
|
|
|
224
|
|
|
$I->assertCount(2, $this->view->assetBundles); |
|
225
|
|
|
|
|
226
|
|
|
$I->assertArrayHasKey(NpmRegularAsset::class, $this->view->assetBundles); |
|
227
|
|
|
$I->assertArrayHasKey(NpmFontAwesomeAsset::class, $this->view->assetBundles); |
|
228
|
|
|
|
|
229
|
|
|
$I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[NpmRegularAsset::class]); |
|
230
|
|
|
$I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[NpmFontAwesomeAsset::class]); |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* testNpmSolidAssetSimpleDependency |
|
235
|
|
|
* |
|
236
|
|
|
* @param UnitTester $I |
|
237
|
|
|
*/ |
|
238
|
|
|
public function testNpmSolidAssetSimpleDependency(UnitTester $I): void |
|
239
|
|
|
{ |
|
240
|
|
|
$I->assertEmpty($this->view->assetBundles); |
|
241
|
|
|
|
|
242
|
|
|
NpmSolidAsset::register($this->view); |
|
243
|
|
|
|
|
244
|
|
|
$I->assertCount(2, $this->view->assetBundles); |
|
245
|
|
|
|
|
246
|
|
|
$I->assertArrayHasKey(NpmSolidAsset::class, $this->view->assetBundles); |
|
247
|
|
|
$I->assertArrayHasKey(NpmFontAwesomeAsset::class, $this->view->assetBundles); |
|
248
|
|
|
|
|
249
|
|
|
$I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[NpmSolidAsset::class]); |
|
250
|
|
|
$I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[NpmFontAwesomeAsset::class]); |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* testNpmAllAssetSourcesPublish |
|
255
|
|
|
* |
|
256
|
|
|
* @param UnitTester $I |
|
257
|
|
|
*/ |
|
258
|
|
|
public function testNpmAllAssetSourcesPublish(UnitTester $I): void |
|
259
|
|
|
{ |
|
260
|
|
|
$bundle = NpmAllAsset::register($this->view); |
|
261
|
|
|
|
|
262
|
|
|
$I->assertTrue(is_dir($bundle->basePath)); |
|
263
|
|
|
|
|
264
|
|
|
$I->sourcesPublishVerifyFiles('js', $bundle); |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
/** |
|
268
|
|
|
* testNpmBrandAssetSourcesPublish |
|
269
|
|
|
* |
|
270
|
|
|
* @param UnitTester $I |
|
271
|
|
|
*/ |
|
272
|
|
|
public function testNpmBrandAssetSourcesPublish(UnitTester $I): void |
|
273
|
|
|
{ |
|
274
|
|
|
$bundle = NpmBrandAsset::register($this->view); |
|
275
|
|
|
|
|
276
|
|
|
$I->assertTrue(is_dir($bundle->basePath)); |
|
277
|
|
|
|
|
278
|
|
|
$I->sourcesPublishVerifyFiles('js', $bundle); |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
/** |
|
282
|
|
|
* testNpmFontAwesomeAssetSourcesPublish |
|
283
|
|
|
* |
|
284
|
|
|
* @param UnitTester $I |
|
285
|
|
|
*/ |
|
286
|
|
|
public function testNpmFontAwesomeAssetSourcesPublish(UnitTester $I): void |
|
287
|
|
|
{ |
|
288
|
|
|
$bundle = NpmFontAwesomeAsset::register($this->view); |
|
289
|
|
|
|
|
290
|
|
|
$I->assertTrue(is_dir($bundle->basePath)); |
|
291
|
|
|
|
|
292
|
|
|
$I->sourcesPublishVerifyFiles('js', $bundle); |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* testNpmRegularAssetSourcesPublish |
|
297
|
|
|
* |
|
298
|
|
|
* @param UnitTester $I |
|
299
|
|
|
*/ |
|
300
|
|
|
public function testNpmRegularAssetSourcesPublish(UnitTester $I): void |
|
301
|
|
|
{ |
|
302
|
|
|
$bundle = NpmRegularAsset::register($this->view); |
|
303
|
|
|
|
|
304
|
|
|
$I->assertTrue(is_dir($bundle->basePath)); |
|
305
|
|
|
|
|
306
|
|
|
$I->sourcesPublishVerifyFiles('js', $bundle); |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
/** |
|
310
|
|
|
* testNpmSolidAssetSourcesPublish |
|
311
|
|
|
* |
|
312
|
|
|
* @param UnitTester $I |
|
313
|
|
|
*/ |
|
314
|
|
|
public function testNpmSolidAssetSourcesPublish(UnitTester $I): void |
|
315
|
|
|
{ |
|
316
|
|
|
$bundle = NpmSolidAsset::register($this->view); |
|
317
|
|
|
|
|
318
|
|
|
$I->assertTrue(is_dir($bundle->basePath)); |
|
319
|
|
|
|
|
320
|
|
|
$I->sourcesPublishVerifyFiles('js', $bundle); |
|
321
|
|
|
} |
|
322
|
|
|
} |
|
323
|
|
|
|