LinkTest.php 45.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 3/31/16
 * Time: 10:06 PM
 */

namespace qfq;

require_once(__DIR__ . '/../../qfq/report/Link.php');
Carsten  Rose's avatar
Carsten Rose committed
12
13
require_once(__DIR__ . '/../../qfq/store/Store.php');
require_once(__DIR__ . '/../../qfq/store/Sip.php');
14
15
16
17


class LinkTest extends \PHPUnit_Framework_TestCase {

Carsten  Rose's avatar
Carsten Rose committed
18
19
20
21
22
23
24
25
26
    /**
     * @var Sip
     */
    private $sip = null;

    /**
     * @var Store
     */
    private $store = null;
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    /**
     * @expectedException \qfq\UserReportException
     */
    public function testUnknownTokenException1() {
        $link = new Link(null, $this->sip, true);

        $link->renderLink('b:hello world');
    }

    /**
     * @expectedException \qfq\UserReportException
     */
    public function testUnknownTokenException2() {
        $link = new Link(null, $this->sip, true);

        $link->renderLink('abc:hello world');
    }

46
47
48
49
50
51
    /**
     * @throws SyntaxReportException
     */
    public function testLinkUrlBasic() {
        $link = new Link(null, $this->sip, true);

52
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);
53

54
        $result = $link->renderLink('');
55
56
57
58
59
        $this->assertEquals('', $result);

        $result = $link->renderLink('u:http://example.com');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

60
61
62
63
64
65
        $result = $link->renderLink('u:http://example.com?id=100&t=2&param=hello');
        $this->assertEquals('<a href="http://example.com?id=100&t=2&param=hello" class="external" >http://example.com?id=100&t=2&param=hello</a>', $result);

        $result = $link->renderLink('u:example.com');
        $this->assertEquals('<a href="example.com" class="external" >example.com</a>', $result);

66
67
        $result = $link->renderLink('u:http://example.com|t:Hello world');
        $this->assertEquals('<a href="http://example.com" class="external" >Hello world</a>', $result);
68
69
70

        $result = $link->renderLink('u:http://example.com?id=100&t=2&param=hello|t:Hello world');
        $this->assertEquals('<a href="http://example.com?id=100&t=2&param=hello" class="external" >Hello world</a>', $result);
71
72
73
74
75
76
77
78
79
    }

    /**
     * @expectedException \qfq\UserReportException
     *
     */
    public function testLinkUrlBasicExceptionDouble() {
        $link = new Link(null, $this->sip, true);

80
81
82
83
84
85
86
87
88
89
90
        $link->renderLink('u:http://example.com|u:http://new.org');
    }

    /**
     * @expectedException \qfq\UserReportException
     *
     */
    public function testLinkUrlBasicExceptionEmpty1() {
        $link = new Link(null, $this->sip, true);

        $link->renderLink('u');
91
92
    }

93
94
95
96
97
98
99
100
101
    /**
     * @expectedException \qfq\UserReportException
     *
     */
    public function testLinkUrlBasicExceptionEmpty2() {
        $link = new Link(null, $this->sip, true);

        $link->renderLink('u:');
    }
102

103
    /**
104
     * @throws SyntaxReportException
105
     */
106
    public function testLinkPageBasic() {
Carsten  Rose's avatar
Carsten Rose committed
107
        $link = new Link(null, $this->sip, true);
108
109
110
111
112
113
114
115
116
117
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);

        $result = $link->renderLink('p');
        $this->assertEquals('<a href="?id=firstPage" class="internal" >?id=firstPage</a>', $result);

        $result = $link->renderLink('p:');
        $this->assertEquals('<a href="?id=firstPage" class="internal" >?id=firstPage</a>', $result);

        $result = $link->renderLink('p:secondPage');
        $this->assertEquals('<a href="?id=secondPage" class="internal" >?id=secondPage</a>', $result);
118

119
120
121
        $result = $link->renderLink('p:id=secondPage');
        $this->assertEquals('<a href="?id=secondPage" class="internal" >?id=secondPage</a>', $result);

122
123
124
        $result = $link->renderLink('p:id=secondPage&id=100&t=2&param=hello');
        $this->assertEquals('<a href="?id=secondPage&id=100&t=2&param=hello" class="internal" >?id=secondPage&id=100&t=2&param=hello</a>', $result);

125
126
        $result = $link->renderLink('p:secondPage|t:Hello world');
        $this->assertEquals('<a href="?id=secondPage" class="internal" >Hello world</a>', $result);
127
128
129
130
131
    }

    /**
     * @throws SyntaxReportException
     */
132
133
134
135
    public function testLinkMailBasic() {
        $link = new Link(null, $this->sip, true);

        $result = $link->renderLink('m:john@doe.com');
136
        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result);
137
138

        $result = $link->renderLink('m:john@doe.com|t:John Doe');
139
        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >John Doe</a>', $result);
140
141
142
143
144
145
146
147
148
    }

    /**
     * @expectedException \qfq\UserReportException
     *
     */
    public function testLinkMailBasicExceptionMissing1() {
        $link = new Link(null, $this->sip, true);

149
        $link->renderLink('m');
150
151
152
153
154
155
156
157
158
    }

    /**
     * @expectedException \qfq\UserReportException
     *
     */
    public function testLinkMailBasicExceptionMissing2() {
        $link = new Link(null, $this->sip, true);

159
        $link->renderLink('m:');
160
161
    }

Carsten  Rose's avatar
Carsten Rose committed
162
163
164
165
166
167
    /**
     * @throws SyntaxReportException
     */
    public function testMailEncryption() {
        $link = new Link(null, $this->sip, true);

168
169
170
171
172
173
        //TODO: aktivieren sobald encrypted Mails implemented.
//        $result = $link->renderLink('m:john@doe.com|e');
//        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result);
//
//        $result = $link->renderLink('m:john@doe.com|e:');
//        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
174
175

        $result = $link->renderLink('m:john@doe.com|e:0');
176
        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
177
178
179
180
181
182
183
184

//        $result = $link->renderLink('m:john@doe.com|e:1');
//        $this->assertEquals('<a href="mailto:john@doe.com" >mailto:john@doe.com</a>', $result);
    }

    /**
     * @throws UserReportException
     */
185
    public function testRenderModeUrl() {
186
        $link = new Link(null, $this->sip, true);
187

188
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);
189

190
191
192
193
        $result = $link->renderLink('u:http://example.com');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        $result = $link->renderLink('t:Example');
194
        $this->assertEquals('', $result);
195

196
197
198
199
        $result = $link->renderLink('u:http://example.com|t:Example');
        $this->assertEquals('<a href="http://example.com" class="external" >Example</a>', $result);

        $result = $link->renderLink('u:http://example.com|r:0');
200
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);
201

202
203
204
205
206
207
208
209
210
211
212
        $result = $link->renderLink('t:Example|r:0');
        $this->assertEquals('', $result);

        $result = $link->renderLink('u:http://example.com|t:Example|r:0');
        $this->assertEquals('<a href="http://example.com" class="external" >Example</a>', $result);

        // r: 1
        $result = $link->renderLink('u:http://example.com|r:1');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        $result = $link->renderLink('t:Example|r:1');
213
214
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230

        $result = $link->renderLink('u:http://example.com|t:Example|r:1');
        $this->assertEquals('<a href="http://example.com" class="external" >Example</a>', $result);

        // r: 2
        $result = $link->renderLink('u:http://example.com|r:2');
        $this->assertEquals('', $result);

        $result = $link->renderLink('t:Example|r:2');
        $this->assertEquals('', $result);

        $result = $link->renderLink('u:http://example.com|t:Example|r:2');
        $this->assertEquals('<a href="http://example.com" class="external" >Example</a>', $result);

        // r: 3
        $result = $link->renderLink('u:http://example.com|r:3');
231
232
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
233
234

        $result = $link->renderLink('t:Example|r:3');
235
236
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
237
238

        $result = $link->renderLink('u:http://example.com|t:Example|r:3');
239
240
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
241
242
243

        // r: 4
        $result = $link->renderLink('u:http://example.com|r:4');
244
245
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
246
247

        $result = $link->renderLink('t:Example|r:4');
248
249
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
250
251

        $result = $link->renderLink('u:http://example.com|t:Example|r:4');
252
253
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
254
255
256
257
258
259
260
261
262
263
264
265

        // r: 5
        $result = $link->renderLink('u:http://example.com|r:5');
        $this->assertEquals('', $result);

        $result = $link->renderLink('t:Example|r:5');
        $this->assertEquals('', $result);

        $result = $link->renderLink('u:http://example.com|t:Example|r:5');
        $this->assertEquals('', $result);
    }

Carsten  Rose's avatar
Carsten Rose committed
266
267
268
269
270
    /**
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
     */
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
    public function testRenderModePage() {
        $link = new Link(null, $this->sip, true);
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);

        // r: default (0)
        $result = $link->renderLink('p');
        $this->assertEquals('<a href="?id=firstPage" class="internal" >?id=firstPage</a>', $result);

        $result = $link->renderLink('p:secondPage');
        $this->assertEquals('<a href="?id=secondPage" class="internal" >?id=secondPage</a>', $result);

        $result = $link->renderLink('t:Example');
        $this->assertEquals('', $result);

        $result = $link->renderLink('p:secondPage|t:Example');
        $this->assertEquals('<a href="?id=secondPage" class="internal" >Example</a>', $result);

        // r: 0
        $result = $link->renderLink('p|r:0');
        $this->assertEquals('<a href="?id=firstPage" class="internal" >?id=firstPage</a>', $result);

        $result = $link->renderLink('p:secondPage|r:0');
        $this->assertEquals('<a href="?id=secondPage" class="internal" >?id=secondPage</a>', $result);

        $result = $link->renderLink('t:Example|r:0');
        $this->assertEquals('', $result);

        $result = $link->renderLink('p:secondPage|t:Example|r:0');
        $this->assertEquals('<a href="?id=secondPage" class="internal" >Example</a>', $result);

        // r: 1
        $result = $link->renderLink('p|r:1');
        $this->assertEquals('<a href="?id=firstPage" class="internal" >?id=firstPage</a>', $result);

        $result = $link->renderLink('p:secondPage|r:1');
        $this->assertEquals('<a href="?id=secondPage" class="internal" >?id=secondPage</a>', $result);

        $result = $link->renderLink('t:Example|r:1');
309
310
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329

        $result = $link->renderLink('p:secondPage|t:Example|r:1');
        $this->assertEquals('<a href="?id=secondPage" class="internal" >Example</a>', $result);

        // r: 2
        $result = $link->renderLink('p|r:2');
        $this->assertEquals('', $result);

        $result = $link->renderLink('p:secondPage|r:2');
        $this->assertEquals('', $result);

        $result = $link->renderLink('t:Example|r:2');
        $this->assertEquals('', $result);

        $result = $link->renderLink('p:secondPage|t:Example|r:2');
        $this->assertEquals('<a href="?id=secondPage" class="internal" >Example</a>', $result);

        // r: 3
        $result = $link->renderLink('p|r:3');
330
331
//        $this->assertEquals('<span >?id=firstPage</span>', $result);
        $this->assertEquals('?id=firstPage', $result);
332
333

        $result = $link->renderLink('p:secondPage|r:3');
334
335
//        $this->assertEquals('<span >?id=secondPage</span>', $result);
        $this->assertEquals('?id=secondPage', $result);
336
337

        $result = $link->renderLink('t:Example|r:3');
338
339
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
340
341

        $result = $link->renderLink('p:secondPage|t:Example|r:3');
342
343
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
344
345
346

        // r: 4
        $result = $link->renderLink('p|r:4');
347
348
//        $this->assertEquals('<span >?id=firstPage</span>', $result);
        $this->assertEquals('?id=firstPage', $result);
349
350

        $result = $link->renderLink('p:secondPage|r:4');
351
352
//        $this->assertEquals('<span >?id=secondPage</span>', $result);
        $this->assertEquals('?id=secondPage', $result);
353
354

        $result = $link->renderLink('t:Example|r:4');
355
356
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
357
358

        $result = $link->renderLink('p:secondPage|t:Example|r:4');
359
360
//        $this->assertEquals('<span >?id=secondPage</span>', $result);
        $this->assertEquals('?id=secondPage', $result);
361

362
363
364
365
366
367
368
369
370
371
372
373
        // r: 5
        $result = $link->renderLink('p|r:5');
        $this->assertEquals('', $result);

        $result = $link->renderLink('p:secondPage|r:5');
        $this->assertEquals('', $result);

        $result = $link->renderLink('t:Example|r:5');
        $this->assertEquals('', $result);

        $result = $link->renderLink('p:secondPage|t:Example|r:5');
        $this->assertEquals('', $result);
374
375
    }

Carsten  Rose's avatar
Carsten Rose committed
376
377
378
    /**
     * @throws UserReportException
     */
379
380
381
382
383
    public function testRenderModeMail() {
        $link = new Link(null, $this->sip, true);

        // r: default (0)
        $result = $link->renderLink('m:john@doe.com');
384
        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result);
385
386
387
388
389

        $result = $link->renderLink('t:Example');
        $this->assertEquals('', $result);

        $result = $link->renderLink('m:john@doe.com|t:Example');
390
        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >Example</a>', $result);
391
392
393

        // r: 0
        $result = $link->renderLink('m:john@doe.com|r:0');
394
        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result);
395
396
397
398
399

        $result = $link->renderLink('t:Example|r:0');
        $this->assertEquals('', $result);

        $result = $link->renderLink('m:john@doe.com|t:Example|r:0');
400
        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >Example</a>', $result);
401
402
403

        // r: 1
        $result = $link->renderLink('m:john@doe.com|r:1');
404
        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result);
405
406

        $result = $link->renderLink('t:Example|r:1');
407
408
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
409
410

        $result = $link->renderLink('m:john@doe.com|t:Example|r:1');
411
        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >Example</a>', $result);
412
413
414
415
416
417
418
419
420

        // r: 2
        $result = $link->renderLink('m:john@doe.com|r:2');
        $this->assertEquals('', $result);

        $result = $link->renderLink('t:Example|r:2');
        $this->assertEquals('', $result);

        $result = $link->renderLink('m:john@doe.com|t:Example|r:2');
421
        $this->assertEquals('<a href="mailto:john@doe.com" class="external" >Example</a>', $result);
422
423
424

        // r: 3
        $result = $link->renderLink('m:john@doe.com|r:3');
425
426
//        $this->assertEquals('<span >mailto:john@doe.com</span>', $result);
        $this->assertEquals('mailto:john@doe.com', $result);
427
428

        $result = $link->renderLink('t:Example|r:3');
429
430
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
431
432

        $result = $link->renderLink('m:john@doe.com|t:Example|r:3');
433
434
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
435
436
437

        // r: 4
        $result = $link->renderLink('m:john@doe.com|r:4');
438
439
//        $this->assertEquals('<span >mailto:john@doe.com</span>', $result);
        $this->assertEquals('mailto:john@doe.com', $result);
440
441

        $result = $link->renderLink('t:Example|r:4');
442
443
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
444
445

        $result = $link->renderLink('m:john@doe.com|t:Example|r:4');
446
447
//        $this->assertEquals('<span >mailto:john@doe.com</span>', $result);
        $this->assertEquals('mailto:john@doe.com', $result);
448
449
450
451
452
453
454
455
456
457
458
459

        // r: 5
        $result = $link->renderLink('m:john@doe.com|r:5');
        $this->assertEquals('', $result);

        $result = $link->renderLink('t:Example|r:5');
        $this->assertEquals('', $result);

        $result = $link->renderLink('m:john@doe.com|t:Example|r:5');
        $this->assertEquals('', $result);
    }

Carsten  Rose's avatar
Carsten Rose committed
460
461
462
    /**
     * @throws UserReportException
     */
463
464
465
466
467
    public function testRenderModeUrlPicture() {
        $link = new Link(null, $this->sip, true);

        // r: default (0)
        $result = $link->renderLink('u:http://example.com|P:picture.gif');
468
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" ></a>', $result);
469
470
471
472
473

        $result = $link->renderLink('t:Example|P:picture.gif');
        $this->assertEquals('', $result);

        $result = $link->renderLink('u:http://example.com|t:Example|P:picture.gif');
474
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result);
475
476
477

        // r: 0
        $result = $link->renderLink('u:http://example.com|r:0|P:picture.gif');
478
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" ></a>', $result);
479
480
481
482
483

        $result = $link->renderLink('t:Example|r:0|P:picture.gif');
        $this->assertEquals('', $result);

        $result = $link->renderLink('u:http://example.com|t:Example|r:0|P:picture.gif');
484
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result);
485
486
487

        // r: 1
        $result = $link->renderLink('u:http://example.com|r:1|P:picture.gif');
488
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" ></a>', $result);
489
490

        $result = $link->renderLink('t:Example|r:1|P:picture.gif');
491
492
//        $this->assertEquals('<span ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result);
        $this->assertEquals('<img alt="picture.gif" src="picture.gif" title="picture.gif" > Example', $result);
493
494

        $result = $link->renderLink('u:http://example.com|t:Example|r:1|P:picture.gif');
495
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result);
496
497
498
499

        // r: 2
        //TODO: no link if text is empty - image is linked here: this is not what the user expects.
        $result = $link->renderLink('u:http://example.com|r:2|P:picture.gif');
500
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" ></a>', $result);
501
502
503
504
505

        $result = $link->renderLink('t:Example|r:2|P:picture.gif');
        $this->assertEquals('', $result);

        $result = $link->renderLink('u:http://example.com|t:Example|r:2|P:picture.gif');
506
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result);
507
508
509

        // r: 3:
        $result = $link->renderLink('u:http://example.com|r:3|P:picture.gif');
510
511
//        $this->assertEquals('<span ><img alt="picture.gif" src="picture.gif" title="picture.gif" > </span>', $result);
        $this->assertEquals('<img alt="picture.gif" src="picture.gif" title="picture.gif" >', $result);
512
513

        $result = $link->renderLink('t:Example|r:3|P:picture.gif');
514
515
//        $this->assertEquals('<span ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result);
        $this->assertEquals('<img alt="picture.gif" src="picture.gif" title="picture.gif" > Example', $result);
516
517

        $result = $link->renderLink('u:http://example.com|t:Example|r:3|P:picture.gif');
518
519
//        $this->assertEquals('<span ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result);
        $this->assertEquals('<img alt="picture.gif" src="picture.gif" title="picture.gif" > Example', $result);
520
521
522

        // r: 4
        $result = $link->renderLink('u:http://example.com|r:4|P:picture.gif');
523
524
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
525
526

        $result = $link->renderLink('t:Example|r:4|P:picture.gif');
527
528
//        $this->assertEquals('<span ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result);
        $this->assertEquals('<img alt="picture.gif" src="picture.gif" title="picture.gif" > Example', $result);
529
530

        $result = $link->renderLink('u:http://example.com|t:Example|r:4|P:picture.gif');
531
532
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
533
534
535
536
537
538
539
540
541
542
543
544

        // r: 5
        $result = $link->renderLink('u:http://example.com|r:5|P:picture.gif');
        $this->assertEquals('', $result);

        $result = $link->renderLink('t:Example|r:5|P:picture.gif');
        $this->assertEquals('', $result);

        $result = $link->renderLink('u:http://example.com|t:Example|r:5|P:picture.gif');
        $this->assertEquals('', $result);
    }

Carsten  Rose's avatar
Carsten Rose committed
545
546
547
548
549
550
551
    /**
     * @throws UserReportException
     */
    public function testIcons() {
        $link = new Link(null, $this->sip, true);

        $result = $link->renderLink('u:http://example.com|E');
552
        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Edit" ><span class="glyphicon glyphicon-pencil" ></span></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
553
554

        $result = $link->renderLink('u:http://example.com|N');
555
        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="New" ><span class="glyphicon glyphicon-plus" ></span></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
556
557

        $result = $link->renderLink('u:http://example.com|D');
558
        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Delete" ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
559
560

        $result = $link->renderLink('u:http://example.com|H');
561
        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Help" ><span class="glyphicon glyphicon glyphicon-question-sign" ></span></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
562
563

        $result = $link->renderLink('u:http://example.com|I');
564
        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Information" ><span class="glyphicon glyphicon glyphicon-info-sign" ></span></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
565
566

        $result = $link->renderLink('u:http://example.com|S');
567
        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Details" ><span class="glyphicon glyphicon glyphicon-search" ></span></a>', $result);
568
569
570

        $result = $link->renderLink('u:http://example.com|E|o:specific');
        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="specific" ><span class="glyphicon glyphicon-pencil" ></span></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
571
572
573
574
575
576
577
578
579
    }

    /**
     * @throws UserReportException
     */
    public function testBullet() {
        $link = new Link(null, $this->sip, true);

        $result = $link->renderLink('u:http://example.com|B');
580
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet green" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
581
582

        $result = $link->renderLink('u:http://example.com|B:green');
583
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet green" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
584
585

        $result = $link->renderLink('u:http://example.com|B:blue');
586
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet blue" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-blue.gif" title="blue" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
587
588

        $result = $link->renderLink('u:http://example.com|B:gray');
589
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet gray" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-gray.gif" title="gray" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
590
591

        $result = $link->renderLink('u:http://example.com|B:pink');
592
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet pink" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-pink.gif" title="pink" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
593
594

        $result = $link->renderLink('u:http://example.com|B:red');
595
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet red" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-red.gif" title="red" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
596
597

        $result = $link->renderLink('u:http://example.com|B:yellow');
598
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet yellow" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-yellow.gif" title="yellow" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
599

600
601
        $result = $link->renderLink('u:http://example.com|B|o:specific');
        $this->assertEquals('<a href="http://example.com" title="specific" ><img alt="Bullet green" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="specific" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
602
603
604
605
606
607
608
609
610
    }

    /**
     * @throws UserReportException
     */
    public function testChecked() {
        $link = new Link(null, $this->sip, true);

        $result = $link->renderLink('u:http://example.com|C');
611
        $this->assertEquals('<a href="http://example.com" ><img alt="Checked green" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="green" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
612
613

        $result = $link->renderLink('u:http://example.com|C:green');
614
        $this->assertEquals('<a href="http://example.com" ><img alt="Checked green" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="green" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
615
616

        $result = $link->renderLink('u:http://example.com|C:blue');
617
        $this->assertEquals('<a href="http://example.com" ><img alt="Checked blue" src="typo3conf/ext/qfq/Resources/Public/icons/checked-blue.gif" title="blue" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
618
619

        $result = $link->renderLink('u:http://example.com|C:gray');
620
        $this->assertEquals('<a href="http://example.com" ><img alt="Checked gray" src="typo3conf/ext/qfq/Resources/Public/icons/checked-gray.gif" title="gray" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
621
622

        $result = $link->renderLink('u:http://example.com|C:pink');
623
        $this->assertEquals('<a href="http://example.com" ><img alt="Checked pink" src="typo3conf/ext/qfq/Resources/Public/icons/checked-pink.gif" title="pink" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
624
625

        $result = $link->renderLink('u:http://example.com|C:red');
626
        $this->assertEquals('<a href="http://example.com" ><img alt="Checked red" src="typo3conf/ext/qfq/Resources/Public/icons/checked-red.gif" title="red" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
627
628

        $result = $link->renderLink('u:http://example.com|C:yellow');
629
        $this->assertEquals('<a href="http://example.com" ><img alt="Checked yellow" src="typo3conf/ext/qfq/Resources/Public/icons/checked-yellow.gif" title="yellow" ></a>', $result);
630
631
632

        $result = $link->renderLink('u:http://example.com|C|o:specific');
        $this->assertEquals('<a href="http://example.com" title="specific" ><img alt="Checked green" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="specific" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
633
634
    }

635
636
637
638
639
640
641
    /**
     * @expectedException \qfq\UserReportException
     */
    public function testPictureException1() {
        $link = new Link(null, $this->sip, true);

        // r: default (0)
642
        $link->renderLink('u:http://www.example.com|P:picture.gif|B');
643
644
645
646
647
648
649
650
651
    }

    /**
     * @expectedException \qfq\UserReportException
     */
    public function testPictureException2() {
        $link = new Link(null, $this->sip, true);

        // r: default (0)
652
        $link->renderLink('u:http://www.example.com|C|B');
653
654
    }

655
656
657
658
659
660
661
    /**
     * @expectedException \qfq\UserReportException
     */
    public function testPictureException3() {
        $link = new Link(null, $this->sip, true);

        // r: default (0)
662
        $link->renderLink('u:http://www.example.com|B:green|B:red');
663
664
665
666
667
668
669
670
671
    }

    /**
     * @expectedException \qfq\UserReportException
     */
    public function testPictureException4() {
        $link = new Link(null, $this->sip, true);

        // r: default (0)
672
        $link->renderLink('u:http://www.example.com|C:green|C:red');
673
    }
674

Carsten  Rose's avatar
Carsten Rose committed
675
676
677
678
679
680
    /**
     * @throws SyntaxReportException
     */
    public function testLinkUrlParam() {
        $link = new Link(null, $this->sip, true);

681
682
683
684
685
686
        $result = $link->renderLink('u:http://example.com|U:');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        $result = $link->renderLink('u:http://example.com|U:');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

Carsten  Rose's avatar
Carsten Rose committed
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
        $result = $link->renderLink('u:http://example.com|U:a=1234');
        $this->assertEquals('<a href="http://example.com?a=1234" class="external" >http://example.com?a=1234</a>', $result);

        $result = $link->renderLink('u:http://example.com|U:a=1234&b=abcd');
        $this->assertEquals('<a href="http://example.com?a=1234&b=abcd" class="external" >http://example.com?a=1234&b=abcd</a>', $result);

        $result = $link->renderLink('u:http://example.com|U:a');
        $this->assertEquals('<a href="http://example.com?a" class="external" >http://example.com?a</a>', $result);

        $result = $link->renderLink('u:http://example.com|U:a=');
        $this->assertEquals('<a href="http://example.com?a=" class="external" >http://example.com?a=</a>', $result);

        $result = $link->renderLink('u:http://example.com?A=hello|U:a=world');
        $this->assertEquals('<a href="http://example.com?A=hello&a=world" class="external" >http://example.com?A=hello&a=world</a>', $result);

        $result = $link->renderLink('u:http://example.com?A=hello&B=nice|U:a=world');
        $this->assertEquals('<a href="http://example.com?A=hello&B=nice&a=world" class="external" >http://example.com?A=hello&B=nice&a=world</a>', $result);

        $result = $link->renderLink('p:form|U:a=1234');
        $this->assertEquals('<a href="?id=form&a=1234" class="internal" >?id=form&a=1234</a>', $result);

        $result = $link->renderLink('p:form|U:a=1234&b=abcd');
        $this->assertEquals('<a href="?id=form&a=1234&b=abcd" class="internal" >?id=form&a=1234&b=abcd</a>', $result);

        $result = $link->renderLink('p:form|U:a');
        $this->assertEquals('<a href="?id=form&a" class="internal" >?id=form&a</a>', $result);

        $result = $link->renderLink('p:form|U:a=');
        $this->assertEquals('<a href="?id=form&a=" class="internal" >?id=form&a=</a>', $result);
    }

    /**
     * @throws SyntaxReportException
     */
    public function testTooltip() {
        $link = new Link(null, $this->sip, true);

        // standard case
        $result = $link->renderLink('u:http://example.com|o:hello world');
        $this->assertEquals('<a href="http://example.com" class="external" title="hello world" >http://example.com</a>', $result);

        // standard case, swapped parameter
        $result = $link->renderLink('o:hello world|u:http://example.com');
        $this->assertEquals('<a href="http://example.com" class="external" title="hello world" >http://example.com</a>', $result);

        // no text: this is ok
        $result = $link->renderLink('u:http://example.com|o');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        // no text: this is ok
        $result = $link->renderLink('u:http://example.com|o:');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        // some text, with double ticks inside
        $result = $link->renderLink('u:http://example.com|o:hello world "some more text" end');
        $this->assertEquals('<a href="http://example.com" class="external" title="hello world \\"some more text\\" end" >http://example.com</a>', $result);

        // some text, with already escaped  double ticks inside
        $result = $link->renderLink('u:http://example.com|o:hello world \\"some more text\\" end');
        $this->assertEquals('<a href="http://example.com" class="external" title="hello world \\"some more text\\" end" >http://example.com</a>', $result);

        // some text with single ticks
        $result = $link->renderLink('u:http://example.com|o:hello world \'some more text\' end');
        $this->assertEquals('<a href="http://example.com" class="external" title="hello world \'some more text\' end" >http://example.com</a>', $result);

        // some text with already escaped single ticks
        $result = $link->renderLink('u:http://example.com|o:hello world \\\'some more text\\\' end');
        $this->assertEquals('<a href="http://example.com" class="external" title="hello world \\\'some more text\\\' end" >http://example.com</a>', $result);
    }

    /**
     * @throws SyntaxReportException
     */
    public function testAltText() {
        $link = new Link(null, $this->sip, true);

        // standard case
        $result = $link->renderLink('u:http://example.com|a:hello world|P:image.gif');
765
        $this->assertEquals('<a href="http://example.com" ><img alt="hello world" src="image.gif" title="image.gif" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
766

Carsten  Rose's avatar
Carsten Rose committed
767
768
769
770
771
        // standard: swapped parameter
        //TODO: fixme
//        $result = $link->renderLink('P:image.gif|a:hello world|u:http://example.com');
//        $this->assertEquals('<a href="http://example.com" ><img alt="hello world" src="image.gif" title="image.gif" ></a>', $result);

Carsten  Rose's avatar
Carsten Rose committed
772
773
        // alt text empty
        $result = $link->renderLink('u:http://example.com|a:|P:image.gif');
774
        $this->assertEquals('<a href="http://example.com" ><img alt="image.gif" src="image.gif" title="image.gif" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798

    }

    /**
     * @throws SyntaxReportException
     */
    public function testClass() {
        $link = new Link(null, $this->sip, true);

        // no class
        $result = $link->renderLink('u:http://example.com|c:n');
        $this->assertEquals('<a href="http://example.com" >http://example.com</a>', $result);

        // internal class
        $result = $link->renderLink('u:http://example.com|c:i');
        $this->assertEquals('<a href="http://example.com" class="internal" >http://example.com</a>', $result);

        // internal class
        $result = $link->renderLink('u:http://example.com|c:e');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        // specific class
        $result = $link->renderLink('u:http://example.com|c:myClass');
        $this->assertEquals('<a href="http://example.com" class="myClass" >http://example.com</a>', $result);
799
800
801
802
803
804
805
806
807
808
809
810

        $result = $link->renderLink('u:http://example.com');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        $result = $link->renderLink('u:http://example.com|c');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        $result = $link->renderLink('u:http://example.com|c:');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        $result = $link->renderLink('p:form');
        $this->assertEquals('<a href="?id=form" class="internal" >?id=form</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
    }

    /**
     * @throws SyntaxReportException
     */
    public function testTarget() {
        $link = new Link(null, $this->sip, true);

        // no target
        $result = $link->renderLink('u:http://example.com|g');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        // no target
        $result = $link->renderLink('u:http://example.com|g:');
        $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result);

        // target _blank
        $result = $link->renderLink('u:http://example.com|g:_blank');
        $this->assertEquals('<a href="http://example.com" class="external" target="_blank" >http://example.com</a>', $result);

        // target someName
        $result = $link->renderLink('u:http://example.com|g:someName');
        $this->assertEquals('<a href="http://example.com" class="external" target="someName" >http://example.com</a>', $result);

        // target someName, swapped parameter
        $result = $link->renderLink('g:someName|u:http://example.com');
        $this->assertEquals('<a href="http://example.com" class="external" target="someName" >http://example.com</a>', $result);
    }

    /**
     * @throws SyntaxReportException
     */
    public function testRight() {
        $link = new Link(null, $this->sip, true);

        // Bullet, LEFT (Standard)
        $result = $link->renderLink('u:http://example.com|t:Hello World|B');
848
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet green" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" > Hello World</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
849
850
851

        // Bullet, RIGHT
        $result = $link->renderLink('u:http://example.com|t:Hello World|B|R');
852
        $this->assertEquals('<a href="http://example.com" >Hello World <img alt="Bullet green" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
853
854
855

        // Checked, LEFT (Standard)
        $result = $link->renderLink('u:http://example.com|t:Hello World|C');
856
        $this->assertEquals('<a href="http://example.com" ><img alt="Checked green" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="green" > Hello World</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
857
858
859

        // Checked, RIGHT
        $result = $link->renderLink('u:http://example.com|t:Hello World|C|R');
860
        $this->assertEquals('<a href="http://example.com" >Hello World <img alt="Checked green" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="green" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
861
862
863

        // Picture, LEFT (Standard)
        $result = $link->renderLink('u:http://example.com|t:Hello World|P:image.gif');
864
        $this->assertEquals('<a href="http://example.com" ><img alt="image.gif" src="image.gif" title="image.gif" > Hello World</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
865
866
867

        // Picture, RIGHT
        $result = $link->renderLink('u:http://example.com|t:Hello World|P:image.gif|R');
868
        $this->assertEquals('<a href="http://example.com" >Hello World <img alt="image.gif" src="image.gif" title="image.gif" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
869
870
871

        // swapped param
        $result = $link->renderLink('R|P:image.gif|t:Hello World|u:http://example.com');
872
        $this->assertEquals('<a href="http://example.com" class="external" >Hello World <img alt="image.gif" src="image.gif" title="image.gif" ></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
873
874
875
876
877
878
879
880
881
    }


    /**
     * @throws SyntaxReportException
     */
    public function testSip() {
        $link = new Link(null, $this->sip, true);

882
        // Sip: URL, s
883
884
        $result = $link->renderLink('u:?form&r=12&xId=2345&L=1&type=99&gId=55|s');
        $this->assertEquals('<a href="index.php?id=form&L=1&type=99&s=badcaffee1234" class="external" >index.php?id=form&L=1&type=99&s=badcaffee1234</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
885

886
887
888
889
890
891
892
893
894
        // Sip: URL, s:0
        $result = $link->renderLink('u:?form&r=12&xId=2345&L=1&type=99&gId=55|s:0');
        $this->assertEquals('<a href="index.php?form&r=12&xId=2345&L=1&type=99&gId=55" class="external" >index.php?form&r=12&xId=2345&L=1&type=99&gId=55</a>', $result);

        // Sip: URL, s:1
        $result = $link->renderLink('u:?form&r=12&xId=2345&L=1&type=99&gId=55|s:1');
        $this->assertEquals('<a href="index.php?id=form&L=1&type=99&s=badcaffee1234" class="external" >index.php?id=form&L=1&type=99&s=badcaffee1234</a>', $result);

        // Sip: Page, s
895
896
        $result = $link->renderLink('p:form&r=12&xId=2345&L=1&type=99&gId=55|s');
        $this->assertEquals('<a href="index.php?id=form&L=1&type=99&s=badcaffee1234" class="internal" >index.php?id=form&L=1&type=99&s=badcaffee1234</a>', $result);
897
898
899
900
901
902
903
904

        // Sip: Page, s:0
        $result = $link->renderLink('p:form&r=12&xId=2345&L=1&type=99&gId=55|s:0');
        $this->assertEquals('<a href="?id=form&r=12&xId=2345&L=1&type=99&gId=55" class="internal" >?id=form&r=12&xId=2345&L=1&type=99&gId=55</a>', $result);

        // Sip: Page, s:1
        $result = $link->renderLink('p:form&r=12&xId=2345&L=1&type=99&gId=55|s:1');
        $this->assertEquals('<a href="index.php?id=form&L=1&type=99&s=badcaffee1234" class="internal" >index.php?id=form&L=1&type=99&s=badcaffee1234</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
905
906
    }

907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
    /**
     * @expectedException \qfq\UserReportException
     */
    public function testSipException1() {
        $link = new Link(null, $this->sip, true);

        // r: default (0)
        $link->renderLink('u:http://www.example.com|s:s');
    }

    /**
     * @expectedException \qfq\UserReportException
     */
    public function testSipException2() {
        $link = new Link(null, $this->sip, true);

        // r: default (0)
        $link->renderLink('u:http://www.example.com|s:2');
    }

Carsten  Rose's avatar
Carsten Rose committed
927
928
929
930
931
932
933
    /**
     * @throws SyntaxReportException
     */
    public function testQuestion() {
        $link = new Link(null, $this->sip, true);

        $js = <<<EOF
934
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
Carsten  Rose's avatar
Carsten Rose committed
935
936
    { label: 'Ok', eventName: 'ok' },
    { label: 'Cancel',eventName: 'cancel'}
937
] } );
Carsten  Rose's avatar
Carsten Rose committed
938
939
940
941
942
943
944
945
alert.on('alert.ok', function() {
  window.location = $('#12345').attr('href');
});

alert.show();
return false;"
EOF;

946
        // Question: all default
Carsten  Rose's avatar
Carsten Rose committed
947
948
949
        $result = $link->renderLink('p:person|c:n|q');
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

950
        // Question: all default
Carsten  Rose's avatar
Carsten Rose committed
951
952
953
        $result = $link->renderLink('p:person|c:n|q:');
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

954
        // Question: individual text
Carsten  Rose's avatar
Carsten Rose committed
955
956
957
958
        $js = str_replace('Please confirm', 'do you really want', $js);
        $result = $link->renderLink('p:person|c:n|q:do you really want');
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

959
960
961
        // Question: individual text, level: warning
        $js = str_replace('info', 'warning', $js);
        $result = $link->renderLink('p:person|c:n|q:do you really want:warning');
Carsten  Rose's avatar
Carsten Rose committed
962
963
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

964
        // Question: individual text, level: warning, positive button: I do
Carsten  Rose's avatar
Carsten Rose committed
965
        $js = str_replace('Ok', 'I do', $js);
966
        $result = $link->renderLink('p:person|c:n|q:do you really want:warning:I do');
Carsten  Rose's avatar
Carsten Rose committed
967
968
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

969
        // Question: individual text, level: warning, positive button: I do, negative button: Shut up
Carsten  Rose's avatar
Carsten Rose committed
970
        $js = str_replace('Cancel', 'Shut up', $js);
971
        $result = $link->renderLink('p:person|c:n|q:do you really want:warning:I do:Shut up');
Carsten  Rose's avatar
Carsten Rose committed
972
973
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

974
        // Question: individual text (with escaped colon)), level: warning, positive button: I do, negative button: Shut up
975
        $js = str_replace('do you really want', 'My Question:some nice value', $js);
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
        $result = $link->renderLink("p:person|c:n|q:My Question\\:some nice value:warning:I do:Shut up");
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

        // Question: individual text (with escaped colon)), level: warning, positive button: I do (with escaped colon), negative button: Shut up
        $js = str_replace('I do', 'I do: hurry up', $js);
        $result = $link->renderLink("p:person|c:n|q:My Question\\:some nice value:warning:I do\\: hurry up:Shut up");
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

        // Timeout:
        $js = str_replace('timeout: 0', 'timeout: 10000', $js);
        $result = $link->renderLink("p:person|c:n|q:My Question\\:some nice value:warning:I do\\: hurry up:Shut up:10");
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

        // Modal: 1
        $result = $link->renderLink("p:person|c:n|q:My Question\\:some nice value:warning:I do\\: hurry up:Shut up:10:1");
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

        // Modal: 0
        $js = str_replace('modal: true', 'modal: false', $js);
        $result = $link->renderLink("p:person|c:n|q:My Question\\:some nice value:warning:I do\\: hurry up:Shut up:10:0");
996
997
        $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result);

Carsten  Rose's avatar
Carsten Rose committed
998
    }
999

Carsten  Rose's avatar
Carsten Rose committed
1000