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

namespace qfq;

11
use PHPUnit\Framework\TestCase;
12

13
14
15
16
17
/**
 * Class LinkTest
 * @package qfq
 */
class LinkTest extends TestCase {
18

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

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

29
30
    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
31
32
33
34
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
35
36
     */
    public function testUnknownTokenException1() {
37
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
38

39
        $link->renderLink('x:hello world');
40
41
42
43
    }

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
44
45
46
47
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
48
49
     */
    public function testUnknownTokenException2() {
50
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
51
52
53
54

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

55
    /**
Carsten  Rose's avatar
Carsten Rose committed
56
57
58
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
59
60
     */
    public function testLinkUrlBasic() {
61
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
62

63
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);
64

65
        $result = $link->renderLink('');
66
67
68
        $this->assertEquals('', $result);

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

71
        $result = $link->renderLink('u:http://example.com?id=100&t=2&param=hello');
72
        $this->assertEquals('<a href="http://example.com?id=100&t=2&param=hello" >http://example.com?id=100&t=2&param=hello</a>', $result);
73
74

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

77
        $result = $link->renderLink('u:http://example.com|t:Hello world');
78
        $this->assertEquals('<a href="http://example.com" >Hello world</a>', $result);
79
80

        $result = $link->renderLink('u:http://example.com?id=100&t=2&param=hello|t:Hello world');
81
        $this->assertEquals('<a href="http://example.com?id=100&t=2&param=hello" >Hello world</a>', $result);
82
83
84
85
86
    }

    /**
     * @expectedException \qfq\UserReportException
     *
Carsten  Rose's avatar
Carsten Rose committed
87
88
89
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
90
91
     */
    public function testLinkUrlBasicExceptionDouble() {
92
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
93

94
95
96
97
        $link->renderLink('u:http://example.com|u:http://new.org');
    }

    /**
Carsten  Rose's avatar
Carsten Rose committed
98
99
100
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
101
     */
102
    public function testLinkPageBasic() {
103
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
104
105
106
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);

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

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

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

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

118
        $result = $link->renderLink('p:id=secondPage&id=100&t=2&param=hello');
119
        $this->assertEquals('<a href="?id=secondPage&id=100&t=2&param=hello" >?id=secondPage&id=100&t=2&param=hello</a>', $result);
120

121
        $result = $link->renderLink('p:secondPage|t:Hello world');
122
        $this->assertEquals('<a href="?id=secondPage" >Hello world</a>', $result);
123
124
125
    }

    /**
Carsten  Rose's avatar
Carsten Rose committed
126
127
128
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
129
     */
130
    public function testLinkMailBasic() {
131
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
132
133

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

        $result = $link->renderLink('m:john@doe.com|t:John Doe');
137
        $this->assertEquals('<a href="mailto:john@doe.com" >John Doe</a>', $result);
138
139
140
    }


Carsten  Rose's avatar
Carsten Rose committed
141
    /**
Carsten  Rose's avatar
Carsten Rose committed
142
143
144
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
Carsten  Rose's avatar
Carsten Rose committed
145
146
     */
    public function testMailEncryption() {
147
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
148

149
150
        //TODO: aktivieren sobald encrypted Mails implemented.
//        $result = $link->renderLink('m:john@doe.com|e');
151
//        $this->assertEquals('<a href="mailto:john@doe.com" >mailto:john@doe.com</a>', $result);
152
153
//
//        $result = $link->renderLink('m:john@doe.com|e:');
154
//        $this->assertEquals('<a href="mailto:john@doe.com" >mailto:john@doe.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
155
156

        $result = $link->renderLink('m:john@doe.com|e:0');
157
        $this->assertEquals('<a href="mailto:john@doe.com" >mailto:john@doe.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
158
159
160
161
162
163

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

    /**
164
165
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
166
167
     * @throws UserReportException
     */
168
    public function testRenderModeUrl() {
169
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
170

171
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);
172

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

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

179
180
181
        $result = $link->renderLink('u|t:Example');
        $this->assertEquals('', $result);

182
        $result = $link->renderLink('u:http://example.com|t:Example');
183
        $this->assertEquals('<a href="http://example.com" >Example</a>', $result);
184
185

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

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

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

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

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

        $result = $link->renderLink('t:Example|r:1');
202
203
204
        $this->assertEquals('Example', $result);

        $result = $link->renderLink('u|t:Example|r:1');
205
        $this->assertEquals('Example', $result);
206
207

        $result = $link->renderLink('u:http://example.com|t:Example|r:1');
208
        $this->assertEquals('<a href="http://example.com" >Example</a>', $result);
209
210
211
212
213
214
215
216

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

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

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

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

        // r: 3
        $result = $link->renderLink('u:http://example.com|r:3');
225
226
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
227
228

        $result = $link->renderLink('t:Example|r:3');
229
230
231
        $this->assertEquals('Example', $result);

        $result = $link->renderLink('u|t:Example|r:3');
232
        $this->assertEquals('Example', $result);
233
234

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

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

        $result = $link->renderLink('t:Example|r:4');
243
244
245
        $this->assertEquals('Example', $result);

        $result = $link->renderLink('u|t:Example|r:4');
246
        $this->assertEquals('Example', $result);
247
248

        $result = $link->renderLink('u:http://example.com|t:Example|r:4');
249
250
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
251
252
253
254
255
256
257
258

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

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

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

262
263
264
265
        $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
    public function testRenderModePage() {
272
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
273
274
275
276
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);

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

        $result = $link->renderLink('p:secondPage');
280
        $this->assertEquals('<a href="?id=secondPage" >?id=secondPage</a>', $result);
281
282
283
284
285

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

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

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

        $result = $link->renderLink('p:secondPage|r:0');
293
        $this->assertEquals('<a href="?id=secondPage" >?id=secondPage</a>', $result);
294
295
296
297
298

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

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

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

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

        $result = $link->renderLink('t:Example|r:1');
309
310
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
311
312

        $result = $link->renderLink('p:secondPage|t:Example|r:1');
313
        $this->assertEquals('<a href="?id=secondPage" >Example</a>', $result);
314
315
316
317
318
319
320
321
322
323
324
325

        // 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');
326
        $this->assertEquals('<a href="?id=secondPage" >Example</a>', $result);
327
328
329

        // 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
    /**
Carsten  Rose's avatar
Carsten Rose committed
377
378
379
380
     * @throws UserReportException
     *
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
381
382
     * @throws UserReportException
     */
383
    public function testRenderModeMail() {
384
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
385
386
387

        // r: default (0)
        $result = $link->renderLink('m:john@doe.com');
388
        $this->assertEquals('<a href="mailto:john@doe.com" >mailto:john@doe.com</a>', $result);
389
390
391
392
393

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

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

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

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

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

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

        $result = $link->renderLink('t:Example|r:1');
411
412
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
413
414

        $result = $link->renderLink('m:john@doe.com|t:Example|r:1');
415
        $this->assertEquals('<a href="mailto:john@doe.com" >Example</a>', $result);
416
417
418
419
420
421
422
423
424

        // 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');
425
        $this->assertEquals('<a href="mailto:john@doe.com" >Example</a>', $result);
426
427
428

        // r: 3
        $result = $link->renderLink('m:john@doe.com|r:3');
429
430
//        $this->assertEquals('<span >mailto:john@doe.com</span>', $result);
        $this->assertEquals('mailto:john@doe.com', $result);
431
432

        $result = $link->renderLink('t:Example|r:3');
433
434
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
435
436

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

        // r: 4
        $result = $link->renderLink('m:john@doe.com|r:4');
442
443
//        $this->assertEquals('<span >mailto:john@doe.com</span>', $result);
        $this->assertEquals('mailto:john@doe.com', $result);
444
445

        $result = $link->renderLink('t:Example|r:4');
446
447
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
448
449

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

        // 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
464
    /**
Carsten  Rose's avatar
Carsten Rose committed
465
466
467
468
     * @throws UserReportException
     *
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
469
470
     * @throws UserReportException
     */
471
    public function testRenderModeUrlPicture() {
472
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
473
474
475

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

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

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

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

        $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');
492
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result);
493
494
495

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

        $result = $link->renderLink('t:Example|r:1|P:picture.gif');
499
500
//        $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);
501
502

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

        // 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');
508
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" ></a>', $result);
509
510
511
512
513

        $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');
514
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result);
515
516
517

        // r: 3:
        $result = $link->renderLink('u:http://example.com|r:3|P:picture.gif');
518
519
//        $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);
520
521

        $result = $link->renderLink('t:Example|r:3|P:picture.gif');
522
523
//        $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);
524
525

        $result = $link->renderLink('u:http://example.com|t:Example|r:3|P:picture.gif');
526
527
//        $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);
528
529
530

        // r: 4
        $result = $link->renderLink('u:http://example.com|r:4|P:picture.gif');
531
532
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
533
534

        $result = $link->renderLink('t:Example|r:4|P:picture.gif');
535
536
//        $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);
537
538

        $result = $link->renderLink('u:http://example.com|t:Example|r:4|P:picture.gif');
539
540
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
541
542
543
544
545
546
547
548
549
550
551
552

        // 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);
    }

553
    /**
Carsten  Rose's avatar
Carsten Rose committed
554
555
556
557
     * @throws UserReportException
     *
     * @throws CodeException
     * @throws UserFormException
558
559
560
     * @throws UserReportException
     */
    public function testRenderModeUrlButton() {
561
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
562
563
564
565
566
567
568
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
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

        // r: default (0)
        $result = $link->renderLink('u:http://example.com|B:yellow');
        $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);

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

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

        // r: 0
        $result = $link->renderLink('u:http://example.com|r:0|B:yellow');
        $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);

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

        $result = $link->renderLink('u:http://example.com|t:Example|r:0|B:yellow');
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet yellow" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-yellow.gif" title="yellow" > Example</a>', $result);

        // r: 1
        $result = $link->renderLink('u:http://example.com|r:1|B:yellow');
        $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);

        $result = $link->renderLink('t:Example|r:1|B:yellow');
        $this->assertEquals('<img alt="Bullet yellow" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-yellow.gif" title="yellow" > Example', $result);

        $result = $link->renderLink('u:http://example.com|t:Example|r:1|B:yellow');
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet yellow" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-yellow.gif" title="yellow" > Example</a>', $result);

        // 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|B:yellow');
        $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);

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

        $result = $link->renderLink('u:http://example.com|t:Example|r:2|B:yellow');
        $this->assertEquals('<a href="http://example.com" ><img alt="Bullet yellow" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-yellow.gif" title="yellow" > Example</a>', $result);

        // r: 3:
        $result = $link->renderLink('u:http://example.com|r:3|B:yellow');
        $this->assertEquals('<img alt="Bullet yellow" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-yellow.gif" title="yellow" >', $result);

        $result = $link->renderLink('t:Example|r:3|B:yellow');
//        $this->assertEquals('<span ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result);
        $this->assertEquals('<img alt="Bullet yellow" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-yellow.gif" title="yellow" > Example', $result);

        $result = $link->renderLink('u:http://example.com|t:Example|r:3|B:yellow');
//        $this->assertEquals('<span ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result);
        $this->assertEquals('<img alt="Bullet yellow" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-yellow.gif" title="yellow" > Example', $result);

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

        $result = $link->renderLink('t:Example|r:4|B:yellow');
//        $this->assertEquals('<span ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result);
        $this->assertEquals('<img alt="Bullet yellow" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-yellow.gif" title="yellow" > Example', $result);

        $result = $link->renderLink('u:http://example.com|t:Example|r:4|B:yellow');
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);

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

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

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

Carsten  Rose's avatar
Carsten Rose committed
640
    /**
Carsten  Rose's avatar
Carsten Rose committed
641
642
643
644
     * @throws UserReportException
     *
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
645
646
647
     * @throws UserReportException
     */
    public function testIcons() {
648
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
649
650

        $result = $link->renderLink('u:http://example.com|E');
651
        $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
652
653

        $result = $link->renderLink('u:http://example.com|N');
654
        $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
655

656
657
658
        $result = $link->renderLink('u:http://example.com|D');
        $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
659
        $result = $link->renderLink('u:http://example.com|H');
660
        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Help" ><span class="glyphicon glyphicon-question-sign" ></span></a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
661
662

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

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

        $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
670
671
672
    }

    /**
Carsten  Rose's avatar
Carsten Rose committed
673
674
675
676
     * @throws UserReportException
     *
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
677
678
679
     * @throws UserReportException
     */
    public function testBullet() {
680
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
681
682

        $result = $link->renderLink('u:http://example.com|B');
683
        $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
684
685

        $result = $link->renderLink('u:http://example.com|B:green');
686
        $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
687
688

        $result = $link->renderLink('u:http://example.com|B:blue');
689
        $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
690
691

        $result = $link->renderLink('u:http://example.com|B:gray');
692
        $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
693
694

        $result = $link->renderLink('u:http://example.com|B:pink');
695
        $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
696
697

        $result = $link->renderLink('u:http://example.com|B:red');
698
        $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
699
700

        $result = $link->renderLink('u:http://example.com|B:yellow');
701
        $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
702

703
704
        $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
705
706
707
    }

    /**
Carsten  Rose's avatar
Carsten Rose committed
708
709
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
710
711
712
     * @throws UserReportException
     */
    public function testChecked() {
713
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
714
715

        $result = $link->renderLink('u:http://example.com|C');
716
        $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
717
718

        $result = $link->renderLink('u:http://example.com|C:green');
719
        $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
720
721

        $result = $link->renderLink('u:http://example.com|C:blue');
722
        $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
723
724

        $result = $link->renderLink('u:http://example.com|C:gray');
725
        $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
726
727

        $result = $link->renderLink('u:http://example.com|C:pink');
728
        $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
729
730

        $result = $link->renderLink('u:http://example.com|C:red');
731
        $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
732
733

        $result = $link->renderLink('u:http://example.com|C:yellow');
734
        $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);
735
736
737

        $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
738
739
    }

740
    /**
Carsten  Rose's avatar
Carsten Rose committed
741
742
     * @throws CodeException
     * @throws UserFormException
743
744
745
     * @throws UserReportException
     */
    public function testGlyph() {
746
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
747
748

        $result = $link->renderLink('u:http://example.com|G:glyphicon-envelope');
749
        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Details" ><span class="glyphicon glyphicon-envelope" ></span></a>', $result);
750
751
752
753
    }

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
754
755
756
757
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
758
759
     */
    public function testGlyphException() {
760
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
761
762
763
764
765

        // Missing 'glyph'-name
        $result = $link->renderLink('u:http://example.com|G');
    }

766
767
    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
768
769
770
771
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
772
773
     */
    public function testPictureException1() {
774
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
775
776

        // r: default (0)
777
        $link->renderLink('u:http://www.example.com|P:picture.gif|B');
778
779
780
781
    }

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
782
783
784
785
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
786
787
     */
    public function testPictureException2() {
788
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
789
790

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

794
795
    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
796
797
798
799
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
800
801
     */
    public function testPictureException3() {
802
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
803
804

        // r: default (0)
805
        $link->renderLink('u:http://www.example.com|B:green|B:red');
806
807
808
809
    }

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
810
811
812
813
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
814
815
     */
    public function testPictureException4() {
816
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
817
818

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

822
823
    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
824
825
826
827
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
828
829
     */
    public function testGlyphExceptionDouble1() {
830
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
831
832
833
834
835
836
837

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

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
838
839
840
841
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
842
843
     */
    public function testGlyphExceptionDouble2() {
844
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
845
846
847
848
849
850
851

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

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
852
853
854
855
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
856
857
     */
    public function testGlyphExceptionDouble3() {
858
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
859
860
861
862
863
864
865

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

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
866
867
868
869
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
870
871
     */
    public function testGlyphExceptionDouble4() {
872
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
873
874
875
876
877
878
879

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

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
880
881
882
883
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
884
885
     */
    public function testGlyphExceptionDouble5() {
886
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
887
888
889
890
891
892
893

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

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
894
895
896
897
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
898
899
     */
    public function testGlyphExceptionDouble6() {
900
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
901
902
903
904
905

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

Carsten  Rose's avatar
Carsten Rose committed
906
    /**
Carsten  Rose's avatar
Carsten Rose committed
907
908
909
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
Carsten  Rose's avatar
Carsten Rose committed
910
911
     */
    public function testLinkUrlParam() {
912
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
913

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

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

Carsten  Rose's avatar
Carsten Rose committed
920
        $result = $link->renderLink('u:http://example.com|U:a=1234');
921
        $this->assertEquals('<a href="http://example.com?a=1234" >http://example.com?a=1234</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
922
923

        $result = $link->renderLink('u:http://example.com|U:a=1234&b=abcd');
924
        $this->assertEquals('<a href="http://example.com?a=1234&b=abcd" >http://example.com?a=1234&b=abcd</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
925
926

        $result = $link->renderLink('u:http://example.com|U:a');
927
        $this->assertEquals('<a href="http://example.com?a" >http://example.com?a</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
928
929

        $result = $link->renderLink('u:http://example.com|U:a=');
930
        $this->assertEquals('<a href="http://example.com?a=" >http://example.com?a=</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
931
932

        $result = $link->renderLink('u:http://example.com?A=hello|U:a=world');
933
        $this->assertEquals('<a href="http://example.com?A=hello&a=world" >http://example.com?A=hello&a=world</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
934
935

        $result = $link->renderLink('u:http://example.com?A=hello&B=nice|U:a=world');
936
        $this->assertEquals('<a href="http://example.com?A=hello&B=nice&a=world" >http://example.com?A=hello&B=nice&a=world</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
937
938

        $result = $link->renderLink('p:form|U:a=1234');
939
        $this->assertEquals('<a href="?id=form&a=1234" >?id=form&a=1234</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
940
941

        $result = $link->renderLink('p:form|U:a=1234&b=abcd');
942
        $this->assertEquals('<a href="?id=form&a=1234&b=abcd" >?id=form&a=1234&b=abcd</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
943
944

        $result = $link->renderLink('p:form|U:a');
945
        $this->assertEquals('<a href="?id=form&a" >?id=form&a</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
946
947

        $result = $link->renderLink('p:form|U:a=');
948
        $this->assertEquals('<a href="?id=form&a=" >?id=form&a=</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
949
950
951
    }

    /**
Carsten  Rose's avatar
Carsten Rose committed
952
953
954
955
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
Carsten  Rose's avatar
Carsten Rose committed
956
957
     */
    public function testTooltip() {
958
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
959
960
961

        // standard case
        $result = $link->renderLink('u:http://example.com|o:hello world');
962
        $this->assertEquals('<a href="http://example.com" title="hello world" >http://example.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
963
964
965

        // standard case, swapped parameter
        $result = $link->renderLink('o:hello world|u:http://example.com');
966
        $this->assertEquals('<a href="http://example.com" title="hello world" >http://example.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
967
968
969

        // no text: this is ok
        $result = $link->renderLink('u:http://example.com|o');
970
        $this->assertEquals('<a href="http://example.com" >http://example.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
971
972
973

        // no text: this is ok
        $result = $link->renderLink('u:http://example.com|o:');
974
        $this->assertEquals('<a href="http://example.com" >http://example.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
975
976
977

        // some text, with double ticks inside
        $result = $link->renderLink('u:http://example.com|o:hello world "some more text" end');
978
        $this->assertEquals('<a href="http://example.com" title="hello world &quot;some more text&quot; end" >http://example.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
979
980
981

        // some text with single ticks
        $result = $link->renderLink('u:http://example.com|o:hello world \'some more text\' end');
982
        $this->assertEquals('<a href="http://example.com" title="hello world \'some more text\' end" >http://example.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
983
984
985
    }

    /**
Carsten  Rose's avatar
Carsten Rose committed
986
987
988
989
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
Carsten  Rose's avatar
Carsten Rose committed
990
991
     */
    public function testAltText() {
Carsten  Rose's avatar