SupportTest.php 29.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 1/28/16
 * Time: 9:58 AM
 */

namespace qfq;

require_once(__DIR__ . '/../../qfq/helper/Support.php');
12
13
require_once(__DIR__ . '/../../qfq/BuildFormPlain.php');
require_once(__DIR__ . '/../../qfq/Evaluate.php');
14

15
16
class FakeTSFE {
    public $id = 1;
17
18
    public $type = 2;
    public $sys_language_uid = 3;
19
}
20

21
class SupportTest extends \PHPUnit_Framework_TestCase {
22

23
24
25
26
27
    /**
     * @var Store
     */
    private $store = null;

28
29
30
31
32
33
    public function testAppendTypo3ParameterToArray() {

        unset($_GET);

        $queryArray = array();
        Support::appendTypo3ParameterToArray($queryArray);
34
        $this->assertEquals(['id' => 1, 'type' => 2, 'L' => 3], $queryArray);
35

36
37
        $queryArray = array();
        $this->store->setVar(TYPO3_PAGE_LANGUAGE, 0, STORE_TYPO3, true);
38
        Support::appendTypo3ParameterToArray($queryArray);
39
        $this->assertEquals(['id' => 1, 'type' => 2], $queryArray);
40

41
42
        $queryArray = array();
        $this->store->setVar(TYPO3_PAGE_TYPE, 0, STORE_TYPO3, true);
43
        Support::appendTypo3ParameterToArray($queryArray);
44
        $this->assertEquals(['id' => 1], $queryArray);
45

46
47
        $queryArray = ['a' => '100'];
        $expected = ['a' => '100', 'id' => 1];
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
        Support::appendTypo3ParameterToArray($queryArray);
        $this->assertEquals($expected, $queryArray);

    }

    public function testArrayToQueryString() {
        $actual = Support::arrayToQueryString(array());
        $expected = '';
        $this->assertEquals($expected, $actual);

        $actual = Support::arrayToQueryString(['id', 'name']);
        $expected = '';
        $this->assertEquals('id&name', $actual);

        $actual = Support::arrayToQueryString(['id' => '55', 'name']);
        $expected = '';
        $this->assertEquals('id=55&name', $actual);

        $actual = Support::arrayToQueryString(['id' => '55', 'name' => 'Heinz']);
        $expected = '';
        $this->assertEquals('id=55&name=Heinz', $actual);

        $actual = Support::arrayToQueryString(['id' => '55', 'name' => 'He<b>inz']);
        $expected = '';
        $this->assertEquals('id=55&name=He%3Cb%3Einz', $actual);
    }
74
75

    public function testWrapTag() {
76
//        $build = new \qfq\BuildFormPlain(array(), array(), array());
77

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
        $result = Support::wrapTag("", '');
        $this->assertEquals('', $result);

        $result = Support::wrapTag(" ", '');
        $this->assertEquals('', $result);

        $result = Support::wrapTag("", ' ');
        $this->assertEquals(' ', $result);

        $result = Support::wrapTag(" ", ' ');
        $this->assertEquals(' ', $result);

        $result = Support::wrapTag("", '', true);
        $this->assertEquals('', $result);

        $result = Support::wrapTag(" ", '', true);
        $this->assertEquals('', $result);

        $result = Support::wrapTag("", ' ', true);
        $this->assertEquals(' ', $result);

        $result = Support::wrapTag(" ", ' ', true);
        $this->assertEquals(' ', $result);

        $result = Support::wrapTag("<p>", '', true);
        $this->assertEquals('', $result);

        $result = Support::wrapTag("<p>", '', false);
        $this->assertEquals('<p></p>', $result);

        $result = Support::wrapTag("<p> ", '', true);
        $this->assertEquals('', $result);

        $result = Support::wrapTag(" <p>", '', false);
        $this->assertEquals('<p></p>', $result);

114
115
116
117
118
119
120
121
122
123
124
125
126
        $result = Support::wrapTag("<p class='test'>", 'Hello World', false);
        $this->assertEquals("<p class='test'>Hello World</p>", $result);

        $result = Support::wrapTag("<p class='test'>", 'Hello World', true);
        $this->assertEquals("<p class='test'>Hello World</p>", $result);

        $result = Support::wrapTag("<p class='test'>", '', false);
        $this->assertEquals("<p class='test'></p>", $result);

        $result = Support::wrapTag("<p class='test'>", '', true);
        $this->assertEquals('', $result);

        $result = Support::wrapTag("<p>", 'Hello World', true);
127
        $this->assertEquals('<p>Hello World</p>', $result);
128
129

        $result = Support::wrapTag("<p>", 'Hello World', false);
130
        $this->assertEquals('<p>Hello World</p>', $result);
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

        $result = Support::wrapTag("<p><i>", 'Hello World', false);
        $this->assertEquals('<p><i>Hello World</i></p>', $result);

        $result = Support::wrapTag("  <p>  <i>  ", 'Hello World', false);
        $this->assertEquals('<p><i>Hello World</i></p>', $result);

        $result = Support::wrapTag("<p><i><strong>", 'Hello World', false);
        $this->assertEquals('<p><i><strong>Hello World</strong></i></p>', $result);

        $result = Support::wrapTag("<p class='test'><i>", 'Hello World', false);
        $this->assertEquals("<p class='test'><i>Hello World</i></p>", $result);

        $result = Support::wrapTag("<p class='test1'><i class='test2'><strong class='test3'>", 'Hello World', false);
        $this->assertEquals("<p class='test1'><i class='test2'><strong class='test3'>Hello World</strong></i></p>", $result);

147
148
    }

149
150
151
    public function testDateTime2mysql() {

        // date
152
        $this->assertEquals('0000-00-00 00:00:00', Support::dateTimeGermanToInternational(''));
153

154
155
156
157
158
        $this->assertEquals('2069-12-31 00:00:00', Support::dateTimeGermanToInternational('31.12.69'));
        $this->assertEquals('1970-01-01 00:00:00', Support::dateTimeGermanToInternational('1.1.70'));
        $this->assertEquals('1999-02-01 00:00:00', Support::dateTimeGermanToInternational('01.02.99'));
        $this->assertEquals('2079-02-01 00:00:00', Support::dateTimeGermanToInternational('1.2.2079'));
        $this->assertEquals('2079-02-01 00:00:00', Support::dateTimeGermanToInternational('01.02.2079'));
159

160
        $this->assertEquals('1234-01-02 00:00:00', Support::dateTimeGermanToInternational('1234-01-02'));
161

162
        // time
163
164
165
166
167
168
        $this->assertEquals('0000-00-00 03:04:00', Support::dateTimeGermanToInternational('3:4'));
        $this->assertEquals('0000-00-00 03:04:00', Support::dateTimeGermanToInternational('03:04'));
        $this->assertEquals('0000-00-00 03:14:00', Support::dateTimeGermanToInternational('3:14'));
        $this->assertEquals('0000-00-00 13:14:00', Support::dateTimeGermanToInternational('13:14'));
        $this->assertEquals('0000-00-00 13:14:01', Support::dateTimeGermanToInternational('13:14:1'));
        $this->assertEquals('0000-00-00 13:14:41', Support::dateTimeGermanToInternational('13:14:41'));
169
170

        // date time
171
172
173
        $this->assertEquals('2069-02-01 01:02:00', Support::dateTimeGermanToInternational('1.2.69 1:2'));
        $this->assertEquals('2016-12-31 23:48:59', Support::dateTimeGermanToInternational('31.12.2016 23:48:59'));
        $this->assertEquals('2016-12-31 23:48:59', Support::dateTimeGermanToInternational('2016-12-31 23:48:59'));
174
175
176
177
178
179
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException01() {
180
        Support::dateTimeGermanToInternational('1');
181
182
183
184
185
186
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException02() {
187
        Support::dateTimeGermanToInternational('1.');
188
189
190
191
192
193
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException03() {
194
        Support::dateTimeGermanToInternational('1.1');
195
196
197
198
199
200
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException04() {
201
        Support::dateTimeGermanToInternational('1.1.');
202
203
204
205
206
207
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException05() {
208
        Support::dateTimeGermanToInternational('1.1.1');
209
210
211
212
213
214
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException06() {
215
        Support::dateTimeGermanToInternational('1.1.1.');
216
217
218
219
220
221
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException07() {
222
        Support::dateTimeGermanToInternational('1.1.1.1');
223
224
225
226
227
228
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException08() {
229
        Support::dateTimeGermanToInternational('123.1.11');
230
231
232
233
234
235
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException09() {
236
        Support::dateTimeGermanToInternational('1.123.11');
237
238
239
240
241
242
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException10() {
243
        Support::dateTimeGermanToInternational('1.1.123');
244
245
246
247
248
249
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException11() {
250
        Support::dateTimeGermanToInternational('1.1.12345');
251
252
253
254
255
256
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException12() {
257
        Support::dateTimeGermanToInternational('1-01-01');
258
259
260
261
262
263
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException13() {
264
        Support::dateTimeGermanToInternational('12-01-01');
265
266
267
268
269
270
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException14() {
271
        Support::dateTimeGermanToInternational('123-01-01');
272
273
274
275
276
277
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException15() {
278
        Support::dateTimeGermanToInternational('12345-01-01');
279
280
281
282
283
284
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException16() {
285
        Support::dateTimeGermanToInternational('1234-1-01');
286
287
288
289
290
291
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException17() {
292
        Support::dateTimeGermanToInternational('1234-01-1');
293
294
295
296
297
298
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException18() {
299
        Support::dateTimeGermanToInternational('1:');
300
301
302
303
304
305
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException19() {
306
        Support::dateTimeGermanToInternational('1:1:');
307
308
309
310
311
312
313
    }


    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException20() {
314
        Support::dateTimeGermanToInternational('1:1:1:1');
315
316
317
318
319
320
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException21() {
321
        Support::dateTimeGermanToInternational('123:1:1');
322
323
324
325
326
327
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException22() {
328
        Support::dateTimeGermanToInternational('1:123:1');
329
330
331
332
333
334
    }

    /**
     * @expectedException \qfq\UserFormException
     */
    public function testDateTime2mysqlException23() {
335
        Support::dateTimeGermanToInternational('1:1:123');
336
    }
337
338

    public function testEncryptDoubleCurlyBraces() {
339
340
341
#/+open+/#
#/+close+/#

342
343
344
345
346
347

        $arr = [
            ['', ''],
            ['1', '1'],
            ["1\n2", "1\n2"],
            ['{', '{'],
348
            ['#/+open+/#', '{{'],
349
            ['-\{-', '-\{-'],
350
351
352
            ['#/+open+/##/+close+/#-#/+open+/##/+close+/#', '{{}}-{{}}'],
            ['#/+open+/#hello#/+open+/#world#/+close+/##/+close+/#', '{{hello{{world}}}}'],
            ["\n\n##/+open+/#\n#/+close+/#", "\n\n#{{\n}}"],
353
354
355
356
357
358
359
360
        ];

        foreach ($arr as $tuple) {
            $this->assertEquals($tuple[0], Support::encryptDoubleCurlyBraces($tuple[1]));
            $this->assertEquals($tuple[1], Support::decryptDoubleCurlyBraces($tuple[0]));
        }
    }

361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
    public function testConcatUrlParam() {
        $url = Support::concatUrlParam('', '');
        $this->assertEquals('', $url);

        $url = Support::concatUrlParam('http://example.com', '');
        $this->assertEquals('http://example.com', $url);

        $url = Support::concatUrlParam('', 'a=1');
        $this->assertEquals('?a=1', $url);

        $url = Support::concatUrlParam('http://example.com', 'a=100');
        $this->assertEquals('http://example.com?a=100', $url);

        $url = Support::concatUrlParam('http://example.com?id=2', 'a=100');
        $this->assertEquals('http://example.com?id=2&a=100', $url);

        $url = Support::concatUrlParam('http://example.com', 'a=100&b=201');
        $this->assertEquals('http://example.com?a=100&b=201', $url);

        $url = Support::concatUrlParam('http://example.com?id=34', 'a=100&b=201');
        $this->assertEquals('http://example.com?id=34&a=100&b=201', $url);
    }

384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
    public function testSetIfNotSet() {
        $new = array();

        Support::setIfNotSet($new, 'id');
        $this->assertEquals(['id' => ''], $new);

        $new = array();
        $new['id'] = 1;
        Support::setIfNotSet($new, 'id');
        $this->assertEquals(['id' => 1], $new);

        $new = array();
        Support::setIfNotSet($new, 'id', 2);
        $this->assertEquals(['id' => 2], $new);

    }
400
401

    public function testEscapeDoubleTick() {
Carsten  Rose's avatar
Carsten Rose committed
402
403
404

        // PLAIN

405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
        // empty string
        $new = Support::escapeDoubleTick('');
        $this->assertEquals('', $new);

        // nothing to replace
        $new = Support::escapeDoubleTick('hello world');
        $this->assertEquals('hello world', $new);

        // last word
        $new = Support::escapeDoubleTick('hello "world"');
        $this->assertEquals('hello \\"world\\"', $new);

        // first word
        $new = Support::escapeDoubleTick('"hello" world');
        $this->assertEquals('\\"hello\\" world', $new);

Carsten  Rose's avatar
Carsten Rose committed
421
422
423
424
        // three double tick
        $new = Support::escapeDoubleTick('"""');
        $this->assertEquals('\\"\\"\\"', $new);

425
426
427
428
        // just "
        $new = Support::escapeDoubleTick('"');
        $this->assertEquals('\\"', $new);

Carsten  Rose's avatar
Carsten Rose committed
429
430
        // already ESCAPED

431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
        // just \"
        $new = Support::escapeDoubleTick('\\"');
        $this->assertEquals('\\"', $new);

        // already escaped: middle
        $new = Support::escapeDoubleTick('hello \\"T world');
        $this->assertEquals('hello \\"T world', $new);

        // already escaped: start
        $new = Support::escapeDoubleTick('\\"T hello world');
        $this->assertEquals('\\"T hello world', $new);

        // already escaped: end
        $new = Support::escapeDoubleTick('hello world \\"');
        $this->assertEquals('hello world \\"', $new);

Carsten  Rose's avatar
Carsten Rose committed
447
448
449
        // three double tick
        $new = Support::escapeDoubleTick('\\"\\"\\"');
        $this->assertEquals('\\"\\"\\"', $new);
450
451
    }

452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
    public function testInsertAttribute() {

        $new = Support::insertAttribute('<i>', 'class', 'qfq');
        $this->assertEquals('<i class="qfq" >', $new);

        $new = Support::insertAttribute('<div>', 'class', 'qfq');
        $this->assertEquals('<div class="qfq" >', $new);

        $new = Support::insertAttribute(' <div> ', 'class', 'qfq');
        $this->assertEquals('<div class="qfq" >', $new);

        $new = Support::insertAttribute('<div >', 'class', 'qfq');
        $this->assertEquals('<div class="qfq" >', $new);

        $new = Support::insertAttribute('<div class="123">', 'class', 'qfq');
        $this->assertEquals('<div class="qfq" class="123">', $new);
    }

470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
    public function testunEscapeNComment() {

        $this->assertEquals('', Support::handleEscapeSpaceComment(''));
        $this->assertEquals('', Support::handleEscapeSpaceComment('   '));

        $this->assertEquals('Hello world.', Support::handleEscapeSpaceComment('Hello world.'));
        $this->assertEquals('Hello world.', Support::handleEscapeSpaceComment('  Hello world.  '));
        $this->assertEquals('', Support::handleEscapeSpaceComment('#Hello world.'));
        $this->assertEquals('', Support::handleEscapeSpaceComment('  #Hello world.  '));
        $this->assertEquals('', Support::handleEscapeSpaceComment('  # Hello world.  '));
        $this->assertEquals('# Hello world.', Support::handleEscapeSpaceComment('\# Hello world.  '));

        $this->assertEquals('Hello world.  ', Support::handleEscapeSpaceComment('Hello world.  \\'));
        $this->assertEquals('Hello world.  ', Support::handleEscapeSpaceComment('Hello world.  \ '));
        $this->assertEquals(' Hello world.', Support::handleEscapeSpaceComment('\ Hello world.'));
        $this->assertEquals(' Hello world. ', Support::handleEscapeSpaceComment('\ Hello world. \ '));
    }

488
489
490
491
492
493
494
    /**
     * @expectedException \qfq\CodeException
     */
    public function testInsertAttributeException1() {
        Support::insertAttribute('<>', 'class', 'qfq');
    }

495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
    /**
     * @expectedException \qfq\CodeException
     */
    public function testMergeUrlComponentsException() {
        Support::mergeUrlComponents('', '', 'sub?id=1');
    }

    public function testMergeUrlComponents() {
        $this->assertEquals('', Support::mergeUrlComponents('', '', ''));

        $this->assertEquals('example.com/', Support::mergeUrlComponents('example.com', '', ''));
        $this->assertEquals('example.com/', Support::mergeUrlComponents('example.com/', '', ''));

        $this->assertEquals('http://example.com/', Support::mergeUrlComponents('http://example.com', '', ''));

        $this->assertEquals('example.com/sub', Support::mergeUrlComponents('example.com', 'sub', ''));
        $this->assertEquals('example.com/sub', Support::mergeUrlComponents('example.com/', 'sub', ''));
        $this->assertEquals('example.com/sub', Support::mergeUrlComponents('example.com', '/sub', ''));
        $this->assertEquals('example.com/sub', Support::mergeUrlComponents('example.com/', '/sub', ''));
        $this->assertEquals('example.com/', Support::mergeUrlComponents('example.com/', '/', ''));

        $this->assertEquals('example.com/sub/sub2', Support::mergeUrlComponents('example.com/sub', 'sub2', ''));
        $this->assertEquals('example.com/sub/sub2', Support::mergeUrlComponents('example.com/sub/', 'sub2', ''));
        $this->assertEquals('example.com/sub/sub2', Support::mergeUrlComponents('example.com/sub', '/sub2', ''));
        $this->assertEquals('example.com/sub/sub2', Support::mergeUrlComponents('example.com/sub/', '/sub2', ''));
        $this->assertEquals('http://example.com/sub', Support::mergeUrlComponents('http://example.com', 'sub', ''));
        $this->assertEquals('http://example.com/sub', Support::mergeUrlComponents('http://example.com/', 'sub', ''));
        $this->assertEquals('http://example.com/sub', Support::mergeUrlComponents('http://example.com/', '/sub', ''));
        $this->assertEquals('http://example.com/sub', Support::mergeUrlComponents('http://example.com', '/sub', ''));

        $this->assertEquals('sub', Support::mergeUrlComponents('', 'sub', ''));
        $this->assertEquals('/sub', Support::mergeUrlComponents('', '/sub', ''));
        $this->assertEquals('/sub/', Support::mergeUrlComponents('', '/sub/', ''));
        $this->assertEquals('/', Support::mergeUrlComponents('', '/', ''));

        $this->assertEquals('example.com/sub?id=1', Support::mergeUrlComponents('example.com', 'sub', 'id=1'));
        $this->assertEquals('example.com/sub?id=1', Support::mergeUrlComponents('example.com', 'sub', '?id=1'));
        $this->assertEquals('example.com/sub/?id=1', Support::mergeUrlComponents('example.com', 'sub/', 'id=1'));
        $this->assertEquals('example.com/sub/?id=1', Support::mergeUrlComponents('example.com', 'sub/', '?id=1'));

        $this->assertEquals('sub?id=1', Support::mergeUrlComponents('', 'sub', 'id=1'));
        $this->assertEquals('/sub?id=1', Support::mergeUrlComponents('', '/sub', '?id=1'));
        $this->assertEquals('sub/?id=1', Support::mergeUrlComponents('', 'sub/', 'id=1'));
        $this->assertEquals('/sub/?id=1', Support::mergeUrlComponents('', '/sub/', '?id=1'));

        $this->assertEquals('example.com/sub/index.php?id=1', Support::mergeUrlComponents('example.com', 'sub/index.php', 'id=1'));
        $this->assertEquals('example.com/sub/index.php?id=1', Support::mergeUrlComponents('example.com', 'sub/index.php', '?id=1'));

        $this->assertEquals('example.com/?id=1', Support::mergeUrlComponents('example.com', '', 'id=1'));
        $this->assertEquals('example.com/?id=1', Support::mergeUrlComponents('example.com', '', '?id=1'));

        $this->assertEquals('example.com/?id=1', Support::mergeUrlComponents('example.com/', '', 'id=1'));
        $this->assertEquals('example.com/?id=1', Support::mergeUrlComponents('example.com/', '', '?id=1'));

        $this->assertEquals('example.com/?id=1', Support::mergeUrlComponents('example.com', '/', 'id=1'));
        $this->assertEquals('example.com/?id=1', Support::mergeUrlComponents('example.com', '/', '?id=1'));

        $this->assertEquals('?', Support::mergeUrlComponents('', '', '?'));
        $this->assertEquals('?id=1', Support::mergeUrlComponents('', '', 'id=1'));
        $this->assertEquals('?id=1', Support::mergeUrlComponents('', '', '?id=1'));

        $this->assertEquals('', Support::mergeUrlComponents('', '', 'index.php'));
        $this->assertEquals('?', Support::mergeUrlComponents('', '', 'index.php?'));
        $this->assertEquals('?id=1', Support::mergeUrlComponents('', '', 'index.php?id=1'));

    }

562
563
564
565
566
567
568
    public function testUnWrapTag() {
        $this->assertEquals('', Support::unWrapTag('', ''));
        $this->assertEquals('', Support::unWrapTag('<p>', ''));
        $this->assertEquals('Hello World', Support::unWrapTag('<p>', 'Hello World'));
        $this->assertEquals('Hello World', Support::unWrapTag('<p>', '<p>Hello World</p>'));
    }

569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
    public function testHtmlEntityEncodeDecode() {
        $this->assertEquals('', Support::htmlEntityEncodeDecode(MODE_NONE, ''));
        $this->assertEquals('test', Support::htmlEntityEncodeDecode(MODE_NONE, 'test'));
        $this->assertEquals('te"st', Support::htmlEntityEncodeDecode(MODE_NONE, 'te"st'));
        $this->assertEquals("te'st", Support::htmlEntityEncodeDecode(MODE_NONE, "te'st"));
        $this->assertEquals("te's\\'t", Support::htmlEntityEncodeDecode(MODE_NONE, "te's\\'t"));
        $this->assertEquals("te & st", Support::htmlEntityEncodeDecode(MODE_NONE, "te & st"));
        $this->assertEquals("te & &amp; st", Support::htmlEntityEncodeDecode(MODE_NONE, "te & &amp; st"));
        $this->assertEquals("te < st", Support::htmlEntityEncodeDecode(MODE_NONE, "te < st"));
        $this->assertEquals("te > st", Support::htmlEntityEncodeDecode(MODE_NONE, "te > st"));
        $this->assertEquals("te &lt; st", Support::htmlEntityEncodeDecode(MODE_NONE, "te &lt; st"));
        $this->assertEquals("te &gt; st", Support::htmlEntityEncodeDecode(MODE_NONE, "te &gt; st"));

        $this->assertEquals('', Support::htmlEntityEncodeDecode(MODE_ENCODE, ''));
        $this->assertEquals('test', Support::htmlEntityEncodeDecode(MODE_ENCODE, 'test'));
        $this->assertEquals('te&quot;st', Support::htmlEntityEncodeDecode(MODE_ENCODE, 'te"st'));
        $this->assertEquals('te&#039;st', Support::htmlEntityEncodeDecode(MODE_ENCODE, "te'st"));
        $this->assertEquals('te&#039;s\&#039;t', Support::htmlEntityEncodeDecode(MODE_ENCODE, "te's\\'t"));
        $this->assertEquals('te &amp; st', Support::htmlEntityEncodeDecode(MODE_ENCODE, "te & st"));
        $this->assertEquals('te &amp; &amp;amp; st', Support::htmlEntityEncodeDecode(MODE_ENCODE, "te & &amp; st"));
        $this->assertEquals("te &lt; st", Support::htmlEntityEncodeDecode(MODE_ENCODE, "te < st"));
        $this->assertEquals("te &gt; st", Support::htmlEntityEncodeDecode(MODE_ENCODE, "te > st"));
        $this->assertEquals("te &amp;lt; st", Support::htmlEntityEncodeDecode(MODE_ENCODE, "te &lt; st"));
        $this->assertEquals("te &amp;gt; st", Support::htmlEntityEncodeDecode(MODE_ENCODE, "te &gt; st"));

        $this->assertEquals('', Support::htmlEntityEncodeDecode(MODE_DECODE, ''));
        $this->assertEquals('test', Support::htmlEntityEncodeDecode(MODE_DECODE, 'test'));
        $this->assertEquals('te"st', Support::htmlEntityEncodeDecode(MODE_DECODE, 'te"st'));
        $this->assertEquals("te'st", Support::htmlEntityEncodeDecode(MODE_DECODE, "te'st"));
        $this->assertEquals("te's\\'t", Support::htmlEntityEncodeDecode(MODE_DECODE, "te's\\'t"));
        $this->assertEquals('te & st', Support::htmlEntityEncodeDecode(MODE_DECODE, "te & st"));
        $this->assertEquals('te & & st', Support::htmlEntityEncodeDecode(MODE_DECODE, "te & &amp; st"));
        $this->assertEquals("te < st", Support::htmlEntityEncodeDecode(MODE_DECODE, "te &lt; st"));
        $this->assertEquals("te > st", Support::htmlEntityEncodeDecode(MODE_DECODE, "te &gt; st"));
    }

605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
    public function testJoinPath() {
        $this->assertEquals('', Support::joinPath('', ''));
        $this->assertEquals('etc', Support::joinPath('etc', ''));
        $this->assertEquals('file', Support::joinPath('', 'file'));
        $this->assertEquals('/etc', Support::joinPath('/etc', ''));
        $this->assertEquals('/file', Support::joinPath('', '/file'));

        $this->assertEquals('etc/', Support::joinPath('etc/', ''));
        $this->assertEquals('file/', Support::joinPath('', 'file/'));
        $this->assertEquals('/etc/', Support::joinPath('/etc/', ''));
        $this->assertEquals('/file/', Support::joinPath('', '/file/'));

        $this->assertEquals('etc/file', Support::joinPath('etc', 'file'));
        $this->assertEquals('/etc/file', Support::joinPath('/etc', 'file'));
        $this->assertEquals('/file', Support::joinPath('etc', '/file'));
        $this->assertEquals('/file', Support::joinPath('/etc', '/file'));
        $this->assertEquals('/file', Support::joinPath('/etc/', '/file'));
        $this->assertEquals('/file/', Support::joinPath('/etc/', '/file/'));

        $this->assertEquals('/etc/etc2/file/file2', Support::joinPath('/etc/etc2', 'file/file2'));
        $this->assertEquals('/etc/etc2/file/file2', Support::joinPath('/etc/etc2/', 'file/file2'));
        $this->assertEquals('/file/file2', Support::joinPath('/etc/etc2/', '/file/file2'));

        #--
        $this->assertEquals('', Support::joinPath('', '', FILE_PRIORITY));
        $this->assertEquals('etc', Support::joinPath('etc', '', FILE_PRIORITY));
        $this->assertEquals('file', Support::joinPath('', 'file', FILE_PRIORITY));
        $this->assertEquals('/etc', Support::joinPath('/etc', '', FILE_PRIORITY));
        $this->assertEquals('/file', Support::joinPath('', '/file', FILE_PRIORITY));

        $this->assertEquals('etc/', Support::joinPath('etc/', '', FILE_PRIORITY));
        $this->assertEquals('file/', Support::joinPath('', 'file/', FILE_PRIORITY));
        $this->assertEquals('/etc/', Support::joinPath('/etc/', '', FILE_PRIORITY));
        $this->assertEquals('/file/', Support::joinPath('', '/file/', FILE_PRIORITY));

        $this->assertEquals('etc/file', Support::joinPath('etc', 'file', FILE_PRIORITY));
        $this->assertEquals('/etc/file', Support::joinPath('/etc', 'file', FILE_PRIORITY));
        $this->assertEquals('/file', Support::joinPath('etc', '/file', FILE_PRIORITY));
        $this->assertEquals('/file', Support::joinPath('/etc', '/file', FILE_PRIORITY));
        $this->assertEquals('/file', Support::joinPath('/etc/', '/file', FILE_PRIORITY));
        $this->assertEquals('/file/', Support::joinPath('/etc/', '/file/', FILE_PRIORITY));

        $this->assertEquals('/etc/etc2/file/file2', Support::joinPath('/etc/etc2', 'file/file2', FILE_PRIORITY));
        $this->assertEquals('/etc/etc2/file/file2', Support::joinPath('/etc/etc2/', 'file/file2', FILE_PRIORITY));
        $this->assertEquals('/file/file2', Support::joinPath('/etc/etc2/', '/file/file2', FILE_PRIORITY));

        #--
        $this->assertEquals('', Support::joinPath('', '', PATH_FILE_CONCAT));
        $this->assertEquals('etc', Support::joinPath('etc', '', PATH_FILE_CONCAT));
        $this->assertEquals('file', Support::joinPath('', 'file', PATH_FILE_CONCAT));
        $this->assertEquals('/etc', Support::joinPath('/etc', '', PATH_FILE_CONCAT));
        $this->assertEquals('/file', Support::joinPath('', '/file', PATH_FILE_CONCAT));

        $this->assertEquals('etc/', Support::joinPath('etc/', '', PATH_FILE_CONCAT));
        $this->assertEquals('file/', Support::joinPath('', 'file/', PATH_FILE_CONCAT));
        $this->assertEquals('/etc/', Support::joinPath('/etc/', '', PATH_FILE_CONCAT));
        $this->assertEquals('/file/', Support::joinPath('', '/file/', PATH_FILE_CONCAT));

        $this->assertEquals('etc/file', Support::joinPath('etc', 'file', PATH_FILE_CONCAT));
        $this->assertEquals('/etc/file', Support::joinPath('/etc', 'file', PATH_FILE_CONCAT));
        $this->assertEquals('etc/file', Support::joinPath('etc', '/file', PATH_FILE_CONCAT));
        $this->assertEquals('/etc/file', Support::joinPath('/etc', '/file', PATH_FILE_CONCAT));
        $this->assertEquals('/etc/file', Support::joinPath('/etc/', '/file', PATH_FILE_CONCAT));
        $this->assertEquals('/etc/file/', Support::joinPath('/etc/', '/file/', PATH_FILE_CONCAT));

        $this->assertEquals('/etc/etc2/file/file2', Support::joinPath('/etc/etc2', 'file/file2', PATH_FILE_CONCAT));
        $this->assertEquals('/etc/etc2/file/file2', Support::joinPath('/etc/etc2/', 'file/file2', PATH_FILE_CONCAT));
        $this->assertEquals('/etc/etc2/file/file2', Support::joinPath('/etc/etc2/', '/file/file2', PATH_FILE_CONCAT));

    }
675

676

677
678
679
680
681
682
    protected function setUp() {
        parent::setUp();

        $GLOBALS["TSFE"] = new FakeTSFE();
        $this->store = Store::getInstance('', true);
    }
683

684
}