LinkTest.php 64.2 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
require_once(__DIR__ . '/../../qfq/store/Session.php');
15
require_once(__DIR__ . '/../../qfq/exceptions/UserReportException.php');
16

17
use PHPUnit\Framework\TestCase;
18

19
20
21
22
23
24
25
//class LinkTest extends \PHPUnit_Framework_TestCase {

/**
 * Class LinkTest
 * @package qfq
 */
class LinkTest extends TestCase {
26

Carsten  Rose's avatar
Carsten Rose committed
27
28
29
30
31
32
33
34
35
    /**
     * @var Sip
     */
    private $sip = null;

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

37
38
    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
39
40
41
42
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
43
44
     */
    public function testUnknownTokenException1() {
45
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
46

47
        $link->renderLink('x:hello world');
48
49
50
51
    }

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

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

63
    /**
Carsten  Rose's avatar
Carsten Rose committed
64
65
66
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
67
68
     */
    public function testLinkUrlBasic() {
69
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
70

71
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);
72

73
        $result = $link->renderLink('');
74
75
76
        $this->assertEquals('', $result);

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

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

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

85
        $result = $link->renderLink('u:http://example.com|t:Hello world');
86
        $this->assertEquals('<a href="http://example.com" >Hello world</a>', $result);
87
88

        $result = $link->renderLink('u:http://example.com?id=100&t=2&param=hello|t:Hello world');
89
        $this->assertEquals('<a href="http://example.com?id=100&t=2&param=hello" >Hello world</a>', $result);
90
91
92
93
94
    }

    /**
     * @expectedException \qfq\UserReportException
     *
Carsten  Rose's avatar
Carsten Rose committed
95
96
97
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
98
99
     */
    public function testLinkUrlBasicExceptionDouble() {
100
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
101

102
103
104
105
        $link->renderLink('u:http://example.com|u:http://new.org');
    }

    /**
Carsten  Rose's avatar
Carsten Rose committed
106
107
108
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
109
     */
110
    public function testLinkPageBasic() {
111
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
112
113
114
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);

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

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

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

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

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

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

    /**
Carsten  Rose's avatar
Carsten Rose committed
134
135
136
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
137
     */
138
    public function testLinkMailBasic() {
139
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
140
141

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

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


Carsten  Rose's avatar
Carsten Rose committed
149
    /**
Carsten  Rose's avatar
Carsten Rose committed
150
151
152
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
Carsten  Rose's avatar
Carsten Rose committed
153
154
     */
    public function testMailEncryption() {
155
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
156

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

        $result = $link->renderLink('m:john@doe.com|e:0');
165
        $this->assertEquals('<a href="mailto:john@doe.com" >mailto:john@doe.com</a>', $result);
Carsten  Rose's avatar
Carsten Rose committed
166
167
168
169
170
171

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

    /**
172
173
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
174
175
     * @throws UserReportException
     */
176
    public function testRenderModeUrl() {
177
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
178

179
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);
180

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

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

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

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

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

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

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

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

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

        $result = $link->renderLink('t:Example|r:1');
210
211
212
        $this->assertEquals('Example', $result);

        $result = $link->renderLink('u|t:Example|r:1');
213
        $this->assertEquals('Example', $result);
214
215

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

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

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

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

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

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

        $result = $link->renderLink('t:Example|r:3');
237
238
239
        $this->assertEquals('Example', $result);

        $result = $link->renderLink('u|t:Example|r:3');
240
        $this->assertEquals('Example', $result);
241
242

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

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

        $result = $link->renderLink('t:Example|r:4');
251
252
253
        $this->assertEquals('Example', $result);

        $result = $link->renderLink('u|t:Example|r:4');
254
        $this->assertEquals('Example', $result);
255
256

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

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

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

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

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

Carsten  Rose's avatar
Carsten Rose committed
274
275
276
277
278
    /**
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
     */
279
    public function testRenderModePage() {
280
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
281
282
283
284
        Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);

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

        $result = $link->renderLink('p:secondPage');
288
        $this->assertEquals('<a href="?id=secondPage" >?id=secondPage</a>', $result);
289
290
291
292
293

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

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

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

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

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

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

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

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

        $result = $link->renderLink('t:Example|r:1');
317
318
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
319
320

        $result = $link->renderLink('p:secondPage|t:Example|r:1');
321
        $this->assertEquals('<a href="?id=secondPage" >Example</a>', $result);
322
323
324
325
326
327
328
329
330
331
332
333

        // 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');
334
        $this->assertEquals('<a href="?id=secondPage" >Example</a>', $result);
335
336
337

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

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

        $result = $link->renderLink('t:Example|r:3');
346
347
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
348
349

        $result = $link->renderLink('p:secondPage|t:Example|r:3');
350
351
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
352
353
354

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

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

        $result = $link->renderLink('t:Example|r:4');
363
364
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
365
366

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

370
371
372
373
374
375
376
377
378
379
380
381
        // 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);
382
383
    }

Carsten  Rose's avatar
Carsten Rose committed
384
    /**
Carsten  Rose's avatar
Carsten Rose committed
385
386
387
388
     * @throws UserReportException
     *
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
389
390
     * @throws UserReportException
     */
391
    public function testRenderModeMail() {
392
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
393
394
395

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

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

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

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

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

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

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

        $result = $link->renderLink('t:Example|r:1');
419
420
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
421
422

        $result = $link->renderLink('m:john@doe.com|t:Example|r:1');
423
        $this->assertEquals('<a href="mailto:john@doe.com" >Example</a>', $result);
424
425
426
427
428
429
430
431
432

        // 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');
433
        $this->assertEquals('<a href="mailto:john@doe.com" >Example</a>', $result);
434
435
436

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

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

        $result = $link->renderLink('m:john@doe.com|t:Example|r:3');
445
446
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
447
448
449

        // r: 4
        $result = $link->renderLink('m:john@doe.com|r:4');
450
451
//        $this->assertEquals('<span >mailto:john@doe.com</span>', $result);
        $this->assertEquals('mailto:john@doe.com', $result);
452
453

        $result = $link->renderLink('t:Example|r:4');
454
455
//        $this->assertEquals('<span >Example</span>', $result);
        $this->assertEquals('Example', $result);
456
457

        $result = $link->renderLink('m:john@doe.com|t:Example|r:4');
458
459
//        $this->assertEquals('<span >mailto:john@doe.com</span>', $result);
        $this->assertEquals('mailto:john@doe.com', $result);
460
461
462
463
464
465
466
467
468
469
470
471

        // 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
472
    /**
Carsten  Rose's avatar
Carsten Rose committed
473
474
475
476
     * @throws UserReportException
     *
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
477
478
     * @throws UserReportException
     */
479
    public function testRenderModeUrlPicture() {
480
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
481
482
483

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

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

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

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

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

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

        $result = $link->renderLink('t:Example|r:1|P:picture.gif');
507
508
//        $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);
509
510

        $result = $link->renderLink('u:http://example.com|t:Example|r:1|P:picture.gif');
511
        $this->assertEquals('<a href="http://example.com" ><img alt="picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result);
512
513
514
515

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

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

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

        $result = $link->renderLink('t:Example|r:3|P:picture.gif');
530
531
//        $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);
532
533

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

        // r: 4
        $result = $link->renderLink('u:http://example.com|r:4|P:picture.gif');
539
540
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
541
542

        $result = $link->renderLink('t:Example|r:4|P:picture.gif');
543
544
//        $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);
545
546

        $result = $link->renderLink('u:http://example.com|t:Example|r:4|P:picture.gif');
547
548
//        $this->assertEquals('<span >http://example.com</span>', $result);
        $this->assertEquals('http://example.com', $result);
549
550
551
552
553
554
555
556
557
558
559
560

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

561
    /**
Carsten  Rose's avatar
Carsten Rose committed
562
563
564
565
     * @throws UserReportException
     *
     * @throws CodeException
     * @throws UserFormException
566
567
568
     * @throws UserReportException
     */
    public function testRenderModeUrlButton() {
569
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
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
640
641
642
643
644
645
646
647

        // 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
648
    /**
Carsten  Rose's avatar
Carsten Rose committed
649
650
651
652
     * @throws UserReportException
     *
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
653
654
655
     * @throws UserReportException
     */
    public function testIcons() {
656
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
657
658

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

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

664
665
666
        $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
667
        $result = $link->renderLink('u:http://example.com|H');
668
        $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
669
670

        $result = $link->renderLink('u:http://example.com|I');
671
        $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
672
673

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

        $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
678
679
680
    }

    /**
Carsten  Rose's avatar
Carsten Rose committed
681
682
683
684
     * @throws UserReportException
     *
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
685
686
687
     * @throws UserReportException
     */
    public function testBullet() {
688
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
689
690

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

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

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

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

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

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

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

711
712
        $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
713
714
715
    }

    /**
Carsten  Rose's avatar
Carsten Rose committed
716
717
     * @throws CodeException
     * @throws UserFormException
Carsten  Rose's avatar
Carsten Rose committed
718
719
720
     * @throws UserReportException
     */
    public function testChecked() {
721
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
722
723

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

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

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

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

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

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

        $result = $link->renderLink('u:http://example.com|C:yellow');
742
        $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);
743
744
745

        $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
746
747
    }

748
    /**
Carsten  Rose's avatar
Carsten Rose committed
749
750
     * @throws CodeException
     * @throws UserFormException
751
752
753
     * @throws UserReportException
     */
    public function testGlyph() {
754
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
755
756

        $result = $link->renderLink('u:http://example.com|G:glyphicon-envelope');
757
        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Details" ><span class="glyphicon glyphicon-envelope" ></span></a>', $result);
758
759
760
761
    }

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

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

774
775
    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
776
777
778
779
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
780
781
     */
    public function testPictureException1() {
782
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
783
784

        // r: default (0)
785
        $link->renderLink('u:http://www.example.com|P:picture.gif|B');
786
787
788
789
    }

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
790
791
792
793
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
794
795
     */
    public function testPictureException2() {
796
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
797
798

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

802
803
    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
804
805
806
807
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
808
809
     */
    public function testPictureException3() {
810
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
811
812

        // r: default (0)
813
        $link->renderLink('u:http://www.example.com|B:green|B:red');
814
815
816
817
    }

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
818
819
820
821
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
822
823
     */
    public function testPictureException4() {
824
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
825
826

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

830
831
    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
832
833
834
835
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
836
837
     */
    public function testGlyphExceptionDouble1() {
838
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
839
840
841
842
843
844
845

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

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
846
847
848
849
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
850
851
     */
    public function testGlyphExceptionDouble2() {
852
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
853
854
855
856
857
858
859

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

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
860
861
862
863
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
864
865
     */
    public function testGlyphExceptionDouble3() {
866
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
867
868
869
870
871
872
873

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

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
874
875
876
877
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
878
879
     */
    public function testGlyphExceptionDouble4() {
880
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
881
882
883
884
885
886
887

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

    /**
     * @expectedException \qfq\UserReportException
Carsten  Rose's avatar
Carsten Rose committed
888
889
890
891
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
892
893
     */
    public function testGlyphExceptionDouble5() {
894
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
895
896
897
898
899
900
901

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

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

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

Carsten  Rose's avatar
Carsten Rose committed
914
    /**
Carsten  Rose's avatar
Carsten Rose committed
915
916
917
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
Carsten  Rose's avatar
Carsten Rose committed
918
919
     */
    public function testLinkUrlParam() {
920
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
921

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

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

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

        $result = $link->renderLink('u:http://example.com|U:a=1234&b=abcd');
932
        $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
933
934

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

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

        $result = $link->renderLink('u:http://example.com?A=hello|U:a=world');
941
        $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
942
943

        $result = $link->renderLink('u:http://example.com?A=hello&B=nice|U:a=world');
944
        $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
945
946

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

        $result = $link->renderLink('p:form|U:a=1234&b=abcd');
950
        $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
951
952

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

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

    /**
Carsten  Rose's avatar
Carsten Rose committed
960
961
962
963
     *
     * @throws CodeException
     * @throws UserFormException
     * @throws UserReportException
Carsten  Rose's avatar
Carsten Rose committed
964
965
     */
    public function testTooltip() {
966
        $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Carsten  Rose's avatar
Carsten Rose committed
967
968
969

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

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

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

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

        // some text, with double ticks inside
        $result = $link->renderLink('u:http://example.com|o:hello world "some more text" end');
986
        $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
987
988
989

        // some text with single ticks
        $result = $link->renderLink('u:http://example.com|o:hello world \'some more text\' end');