omit the PHP closing tag at EOF in all PHP files
[racktables] / tests / StringInsertHrefsTest.php
1 <?php
2
3 class StringInsertHrefsTest extends PHPUnit_Framework_TestCase
4 {
5 protected static $detect_urls_var;
6
7 public static function setUpBeforeClass ()
8 {
9 // make sure DETECT_URLS is set to yes
10 self::$detect_urls_var = getConfigVar ('DETECT_URLS');
11 if (self::$detect_urls_var != 'yes')
12 setConfigVar ('DETECT_URLS', 'yes');
13 }
14
15 public static function tearDownAfterClass ()
16 {
17 // restore DETECT_URLS to original setting
18 if (self::$detect_urls_var != 'yes')
19 setConfigVar ('DETECT_URLS', self::$detect_urls_var);
20 }
21
22 /**
23 * @group small
24 * @dataProvider provider
25 */
26 public function testStringInsertHrefs ($input, $output)
27 {
28 $this->assertEquals ($output, string_insert_hrefs ($input));
29 }
30
31 public function provider ()
32 {
33 return array
34 (
35 array
36 (
37 'This is a string with no links.',
38 'This is a string with no links.'
39 ),
40 array
41 (
42 'http://server/wiki/index.php/objectname',
43 '<a href="http://server/wiki/index.php/objectname">http://server/wiki/index.php/objectname</a> [<a href="http://server/wiki/index.php/objectname" target="_blank">^</a>]'
44 ),
45 array
46 (
47 'http://user:pass@www.example.tld/',
48 '<a href="http://user:pass@www.example.tld/">http://user:pass@www.example.tld/</a> [<a href="http://user:pass@www.example.tld/" target="_blank">^</a>]'
49 ),
50 array
51 (
52 'username@example.tld',
53 '<a href="mailto:username@example.tld">username@example.tld</a>'
54 )
55 );
56 }
57 }