1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Tests\Template; |
3
|
|
|
|
4
|
|
|
use Redaxscript\Template; |
5
|
|
|
use Redaxscript\Tests\TestCaseAbstract; |
6
|
|
|
use org\bovigo\vfs\vfsStream as Stream; |
7
|
|
|
use org\bovigo\vfs\vfsStreamFile as StreamFile; |
8
|
|
|
use org\bovigo\vfs\vfsStreamWrapper as StreamWrapper; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* TagTest |
12
|
|
|
* |
13
|
|
|
* @since 2.3.0 |
14
|
|
|
* |
15
|
|
|
* @package Redaxscript |
16
|
|
|
* @category Tests |
17
|
|
|
* @author Henry Ruhs |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
class TagTest extends TestCaseAbstract |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* setUp |
24
|
|
|
* |
25
|
|
|
* @since 3.1.0 |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
public function setUp() |
29
|
|
|
{ |
30
|
|
|
parent::setUp(); |
31
|
|
|
$optionArray = |
32
|
|
|
[ |
33
|
|
|
'adminName' => 'Test', |
34
|
|
|
'adminUser' => 'test', |
35
|
|
|
'adminPassword' => 'test', |
36
|
|
|
'adminEmail' => '[email protected]' |
37
|
|
|
]; |
38
|
|
|
$installer = $this->installerFactory(); |
39
|
|
|
$installer->init(); |
40
|
|
|
$installer->rawCreate(); |
41
|
|
|
$installer->insertCategories($optionArray); |
42
|
|
|
$installer->insertArticles($optionArray); |
43
|
|
|
$installer->insertComments($optionArray); |
44
|
|
|
$installer->insertSettings($optionArray); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* tearDown |
49
|
|
|
* |
50
|
|
|
* @since 3.1.0 |
51
|
|
|
*/ |
52
|
|
|
|
53
|
|
|
public function tearDown() |
54
|
|
|
{ |
55
|
|
|
$installer = $this->installerFactory(); |
56
|
|
|
$installer->init(); |
57
|
|
|
$installer->rawDrop(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* testBase |
62
|
|
|
* |
63
|
|
|
* @since 3.0.0 |
64
|
|
|
*/ |
65
|
|
|
|
66
|
|
|
public function testBase() |
67
|
|
|
{ |
68
|
|
|
/* actual */ |
69
|
|
|
|
70
|
|
|
$actual = Template\Tag::base(); |
71
|
|
|
|
72
|
|
|
/* compare */ |
73
|
|
|
|
74
|
|
|
$this->assertString($actual); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* testTitle |
79
|
|
|
* |
80
|
|
|
* @since 3.0.0 |
81
|
|
|
*/ |
82
|
|
|
|
83
|
|
|
public function testTitle() |
84
|
|
|
{ |
85
|
|
|
/* actual */ |
86
|
|
|
|
87
|
|
|
$actual = Template\Tag::title('test'); |
88
|
|
|
|
89
|
|
|
/* compare */ |
90
|
|
|
|
91
|
|
|
$this->assertString($actual); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* testLink |
96
|
|
|
* |
97
|
|
|
* @since 3.0.0 |
98
|
|
|
*/ |
99
|
|
|
|
100
|
|
|
public function testLink() |
101
|
|
|
{ |
102
|
|
|
/* actual */ |
103
|
|
|
|
104
|
|
|
$actual = Template\Tag::link(); |
105
|
|
|
|
106
|
|
|
/* compare */ |
107
|
|
|
|
108
|
|
|
$this->assertInstanceOf('Redaxscript\Head\Link', $actual); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* testMeta |
113
|
|
|
* |
114
|
|
|
* @since 3.0.0 |
115
|
|
|
*/ |
116
|
|
|
|
117
|
|
|
public function testMeta() |
118
|
|
|
{ |
119
|
|
|
/* actual */ |
120
|
|
|
|
121
|
|
|
$actual = Template\Tag::meta(); |
122
|
|
|
|
123
|
|
|
/* compare */ |
124
|
|
|
|
125
|
|
|
$this->assertInstanceOf('Redaxscript\Head\Meta', $actual); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* testScript |
130
|
|
|
* |
131
|
|
|
* @since 3.0.0 |
132
|
|
|
*/ |
133
|
|
|
|
134
|
|
|
public function testScript() |
135
|
|
|
{ |
136
|
|
|
/* actual */ |
137
|
|
|
|
138
|
|
|
$actual = Template\Tag::script(); |
139
|
|
|
|
140
|
|
|
/* compare */ |
141
|
|
|
|
142
|
|
|
$this->assertInstanceOf('Redaxscript\Head\Script', $actual); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* testStyle |
147
|
|
|
* |
148
|
|
|
* @since 3.0.0 |
149
|
|
|
*/ |
150
|
|
|
|
151
|
|
|
public function testStyle() |
152
|
|
|
{ |
153
|
|
|
/* actual */ |
154
|
|
|
|
155
|
|
|
$actual = Template\Tag::style(); |
156
|
|
|
|
157
|
|
|
/* compare */ |
158
|
|
|
|
159
|
|
|
$this->assertInstanceOf('Redaxscript\Head\Style', $actual); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* testBreadcrumb |
164
|
|
|
* |
165
|
|
|
* @since 2.3.0 |
166
|
|
|
*/ |
167
|
|
|
|
168
|
|
|
public function testBreadcrumb() |
169
|
|
|
{ |
170
|
|
|
/* actual */ |
171
|
|
|
|
172
|
|
|
$actual = Template\Tag::breadcrumb(); |
173
|
|
|
|
174
|
|
|
/* compare */ |
175
|
|
|
|
176
|
|
|
$this->assertString($actual); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* testConsoleLine |
181
|
|
|
* |
182
|
|
|
* @since 3.0.0 |
183
|
|
|
*/ |
184
|
|
|
|
185
|
|
|
public function testConsoleLine() |
186
|
|
|
{ |
187
|
|
|
/* setup */ |
188
|
|
|
|
189
|
|
|
$this->_request->setPost('argv', 'help'); |
190
|
|
|
|
191
|
|
|
/* actual */ |
192
|
|
|
|
193
|
|
|
$actual = Template\Tag::consoleLine(); |
194
|
|
|
|
195
|
|
|
/* compare */ |
196
|
|
|
|
197
|
|
|
$this->assertString($actual); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* testConsoleLineInvalid |
202
|
|
|
* |
203
|
|
|
* @since 3.0.0 |
204
|
|
|
*/ |
205
|
|
|
|
206
|
|
|
public function testConsoleLineInvalid() |
207
|
|
|
{ |
208
|
|
|
/* setup */ |
209
|
|
|
|
210
|
|
|
$this->_request->setPost('argv', 'invalidCommand'); |
211
|
|
|
|
212
|
|
|
/* actual */ |
213
|
|
|
|
214
|
|
|
$actual = Template\Tag::consoleLine(); |
215
|
|
|
|
216
|
|
|
/* compare */ |
217
|
|
|
|
218
|
|
|
$this->assertFalse($actual); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* testConsoleForm |
223
|
|
|
* |
224
|
|
|
* @since 3.0.0 |
225
|
|
|
*/ |
226
|
|
|
|
227
|
|
|
public function testConsoleForm() |
228
|
|
|
{ |
229
|
|
|
/* actual */ |
230
|
|
|
|
231
|
|
|
$actual = Template\Tag::consoleForm(); |
232
|
|
|
|
233
|
|
|
/* compare */ |
234
|
|
|
|
235
|
|
|
$this->assertString($actual); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* testSearchForm |
240
|
|
|
* |
241
|
|
|
* @since 3.0.0 |
242
|
|
|
*/ |
243
|
|
|
|
244
|
|
|
public function testSearchForm() |
245
|
|
|
{ |
246
|
|
|
/* actual */ |
247
|
|
|
|
248
|
|
|
$actual = Template\Tag::searchForm(); |
249
|
|
|
|
250
|
|
|
/* compare */ |
251
|
|
|
|
252
|
|
|
$this->assertString($actual); |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* testPartial |
257
|
|
|
* |
258
|
|
|
* @since 2.3.0 |
259
|
|
|
*/ |
260
|
|
|
|
261
|
|
|
public function testPartial() |
262
|
|
|
{ |
263
|
|
|
/* setup */ |
264
|
|
|
|
265
|
|
|
Stream::setup('root'); |
266
|
|
|
$file = new StreamFile('partial.phtml'); |
267
|
|
|
StreamWrapper::getRoot()->addChild($file); |
268
|
|
|
|
269
|
|
|
/* actual */ |
270
|
|
|
|
271
|
|
|
$actual = Template\Tag::partial(Stream::url('root/partial.phtml')); |
272
|
|
|
|
273
|
|
|
/* compare */ |
274
|
|
|
|
275
|
|
|
$this->assertString($actual); |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* testGetRegistry |
280
|
|
|
* |
281
|
|
|
* @since 2.6.0 |
282
|
|
|
*/ |
283
|
|
|
|
284
|
|
|
public function testGetRegistry() |
285
|
|
|
{ |
286
|
|
|
/* setup */ |
287
|
|
|
|
288
|
|
|
$this->_registry->set('testKey', 'testValue'); |
289
|
|
|
|
290
|
|
|
/* actual */ |
291
|
|
|
|
292
|
|
|
$actual = Template\Tag::getRegistry('testKey'); |
293
|
|
|
|
294
|
|
|
/* compare */ |
295
|
|
|
|
296
|
|
|
$this->assertEquals('testValue', $actual); |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* testGetLanguage |
301
|
|
|
* |
302
|
|
|
* @since 2.6.0 |
303
|
|
|
*/ |
304
|
|
|
|
305
|
|
|
public function testGetLanguage() |
306
|
|
|
{ |
307
|
|
|
/* setup */ |
308
|
|
|
|
309
|
|
|
$this->_language->set('testKey', 'testValue'); |
310
|
|
|
|
311
|
|
|
/* actual */ |
312
|
|
|
|
313
|
|
|
$actual = Template\Tag::getLanguage('testKey'); |
314
|
|
|
|
315
|
|
|
/* compare */ |
316
|
|
|
|
317
|
|
|
$this->assertEquals('testValue', $actual); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* testGetSetting |
322
|
|
|
* |
323
|
|
|
* @since 2.6.0 |
324
|
|
|
*/ |
325
|
|
|
|
326
|
|
|
public function testGetSetting() |
327
|
|
|
{ |
328
|
|
|
/* actual */ |
329
|
|
|
|
330
|
|
|
$actual = Template\Tag::getSetting('charset'); |
331
|
|
|
|
332
|
|
|
/* compare */ |
333
|
|
|
|
334
|
|
|
$this->assertEquals('utf-8', $actual); |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* testCategoryRaw |
339
|
|
|
* |
340
|
|
|
* @since 3.0.0 |
341
|
|
|
*/ |
342
|
|
|
|
343
|
|
|
public function testCategoryRaw() |
344
|
|
|
{ |
345
|
|
|
/* actual */ |
346
|
|
|
|
347
|
|
|
$actual = Template\Tag::categoryRaw(); |
348
|
|
|
|
349
|
|
|
/* compare */ |
350
|
|
|
|
351
|
|
|
$this->assertInstanceOf('Redaxscript\Db', $actual); |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
/** |
355
|
|
|
* testArticleRaw |
356
|
|
|
* |
357
|
|
|
* @since 3.0.0 |
358
|
|
|
*/ |
359
|
|
|
|
360
|
|
|
public function testArticleRaw() |
361
|
|
|
{ |
362
|
|
|
/* actual */ |
363
|
|
|
|
364
|
|
|
$actual = Template\Tag::articleRaw(); |
365
|
|
|
|
366
|
|
|
/* compare */ |
367
|
|
|
|
368
|
|
|
$this->assertInstanceOf('Redaxscript\Db', $actual); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* testExtraRaw |
373
|
|
|
* |
374
|
|
|
* @since 3.0.0 |
375
|
|
|
*/ |
376
|
|
|
|
377
|
|
|
public function testExtraRaw() |
378
|
|
|
{ |
379
|
|
|
/* actual */ |
380
|
|
|
|
381
|
|
|
$actual = Template\Tag::extraRaw(); |
382
|
|
|
|
383
|
|
|
/* compare */ |
384
|
|
|
|
385
|
|
|
$this->assertInstanceOf('Redaxscript\Db', $actual); |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
/** |
389
|
|
|
* testNavigationCategories |
390
|
|
|
* |
391
|
|
|
* @since 3.3.1 |
392
|
|
|
*/ |
393
|
|
|
|
394
|
|
|
public function testNavigationCategories() |
395
|
|
|
{ |
396
|
|
|
/* actual */ |
397
|
|
|
|
398
|
|
|
$actual = Template\Tag::navigation('categories'); |
399
|
|
|
|
400
|
|
|
/* compare */ |
401
|
|
|
|
402
|
|
|
$this->assertInstanceOf('Redaxscript\Navigation\Category', $actual); |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* testNavigationArticles |
407
|
|
|
* |
408
|
|
|
* @since 3.3.1 |
409
|
|
|
*/ |
410
|
|
|
|
411
|
|
|
public function testNavigationArticles() |
412
|
|
|
{ |
413
|
|
|
/* actual */ |
414
|
|
|
|
415
|
|
|
$actual = Template\Tag::navigation('articles'); |
416
|
|
|
|
417
|
|
|
/* compare */ |
418
|
|
|
|
419
|
|
|
$this->assertInstanceOf('Redaxscript\Navigation\Article', $actual); |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* testNavigationComments |
424
|
|
|
* |
425
|
|
|
* @since 3.3.1 |
426
|
|
|
*/ |
427
|
|
|
|
428
|
|
|
public function testNavigationComments() |
429
|
|
|
{ |
430
|
|
|
/* actual */ |
431
|
|
|
|
432
|
|
|
$actual = Template\Tag::navigation('comments'); |
433
|
|
|
|
434
|
|
|
/* compare */ |
435
|
|
|
|
436
|
|
|
$this->assertInstanceOf('Redaxscript\Navigation\Comment', $actual); |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
/** |
440
|
|
|
* testNavigationLanguages |
441
|
|
|
* |
442
|
|
|
* @since 3.3.1 |
443
|
|
|
*/ |
444
|
|
|
|
445
|
|
|
public function testNavigationLanguages() |
446
|
|
|
{ |
447
|
|
|
/* actual */ |
448
|
|
|
|
449
|
|
|
$actual = Template\Tag::navigation('languages'); |
450
|
|
|
|
451
|
|
|
/* compare */ |
452
|
|
|
|
453
|
|
|
$this->assertInstanceOf('Redaxscript\Navigation\Language', $actual); |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* testNavigationTemplates |
458
|
|
|
* |
459
|
|
|
* @since 3.3.1 |
460
|
|
|
*/ |
461
|
|
|
|
462
|
|
|
public function testNavigationTemplates() |
463
|
|
|
{ |
464
|
|
|
/* actual */ |
465
|
|
|
|
466
|
|
|
$actual = Template\Tag::navigation('templates'); |
467
|
|
|
|
468
|
|
|
/* compare */ |
469
|
|
|
|
470
|
|
|
$this->assertInstanceOf('Redaxscript\Navigation\Template', $actual); |
471
|
|
|
} |
472
|
|
|
} |
473
|
|
|
|