commit | author | age
|
5f8ada
|
1 |
<?php |
AM |
2 |
|
|
3 |
/** |
|
4 |
* Test class to test rcube_string_replacer class |
|
5 |
* |
|
6 |
* @package Tests |
|
7 |
*/ |
|
8 |
class Framework_StringReplacer extends PHPUnit_Framework_TestCase |
|
9 |
{ |
|
10 |
|
|
11 |
/** |
|
12 |
* Class constructor |
|
13 |
*/ |
|
14 |
function test_class() |
|
15 |
{ |
|
16 |
$sr = new rcube_string_replacer; |
|
17 |
|
|
18 |
$this->assertInstanceOf('rcube_string_replacer', $sr, "Class constructor"); |
|
19 |
} |
22c67d
|
20 |
|
AM |
21 |
/** |
|
22 |
* Data for test_replace() |
|
23 |
*/ |
|
24 |
function data_replace() |
|
25 |
{ |
|
26 |
return array( |
1e3254
|
27 |
array('http://domain.tld/path*path2', '<a href="http://domain.tld/path*path2">http://domain.tld/path*path2</a>'), |
AM |
28 |
array("Click this link:\nhttps://mail.xn--brderli-o2a.ch/rc/ EOF", "Click this link:\n<a href=\"https://mail.xn--brderli-o2a.ch/rc/\">https://mail.xn--brderli-o2a.ch/rc/</a> EOF"), |
|
29 |
array('Start http://localhost/?foo End', 'Start <a href="http://localhost/?foo">http://localhost/?foo</a> End'), |
|
30 |
array('www.domain.tld', '<a href="http://www.domain.tld">www.domain.tld</a>'), |
|
31 |
array('WWW.DOMAIN.TLD', '<a href="http://WWW.DOMAIN.TLD">WWW.DOMAIN.TLD</a>'), |
|
32 |
array('[http://link.com]', '[<a href="http://link.com">http://link.com</a>]'), |
|
33 |
array('http://link.com?a[]=1', '<a href="http://link.com?a[]=1">http://link.com?a[]=1</a>'), |
|
34 |
array('http://link.com?a[]', '<a href="http://link.com?a[]">http://link.com?a[]</a>'), |
|
35 |
array('(http://link.com)', '(<a href="http://link.com">http://link.com</a>)'), |
|
36 |
array('http://link.com?a(b)c', '<a href="http://link.com?a(b)c">http://link.com?a(b)c</a>'), |
|
37 |
array('http://link.com?(link)', '<a href="http://link.com?(link)">http://link.com?(link)</a>'), |
16915e
|
38 |
array('http://<test>', 'http://<test>'), |
AM |
39 |
array('http://', 'http://'), |
70229c
|
40 |
array('1@1.com www.domain.tld', '<a href="mailto:1@1.com">1@1.com</a> <a href="http://www.domain.tld">www.domain.tld</a>'), |
AM |
41 |
array(' www.domain.tld ', ' <a href="http://www.domain.tld">www.domain.tld</a> '), |
22c67d
|
42 |
); |
AM |
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* @dataProvider data_replace |
|
47 |
*/ |
|
48 |
function test_replace($input, $output) |
|
49 |
{ |
|
50 |
$replacer = new rcube_string_replacer; |
|
51 |
$result = $replacer->replace($input); |
|
52 |
$result = $replacer->resolve($result); |
|
53 |
|
|
54 |
$this->assertEquals($output, $result); |
|
55 |
} |
5f8ada
|
56 |
} |