]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - tests/URLDetectionTest.php
Merge branch '0.8.x' of git://gitorious.org/~brion/statusnet/brion-fixes into 0.8.x
[quix0rs-gnu-social.git] / tests / URLDetectionTest.php
index 05c02d6bb5a9ed96ec6953b3f00c4fbdff071a53..1c3f7cd96f073d64a8eede2527f61af14ef5aaef 100644 (file)
@@ -6,7 +6,7 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
 }
 
 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
+define('STATUSNET', true);
 
 require_once INSTALLDIR . '/lib/common.php';
 
@@ -25,16 +25,48 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
     static public function provider()
     {
         return array(
+                     array('not a link :: no way',
+                           'not a link :: no way'),
+                     array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
+                           'link <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="external">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
+                     array('http://127.0.0.1',
+                           '<a href="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
                      array('127.0.0.1',
                            '<a href="http://127.0.0.1/" rel="external">127.0.0.1</a>'),
-                     array('127.0.0.1/test.php',
-                           '<a href="http://127.0.0.1/test.php" rel="external">127.0.0.1/test.php</a>'),
+                     array('127.0.0.1:99',
+                           '<a href="http://127.0.0.1:99/" rel="external">127.0.0.1:99</a>'),
+                     array('127.0.0.1/Name:test.php',
+                           '<a href="http://127.0.0.1/Name:test.php" rel="external">127.0.0.1/Name:test.php</a>'),
+                     array('127.0.0.1/~test',
+                           '<a href="http://127.0.0.1/~test" rel="external">127.0.0.1/~test</a>'),
+                     array('127.0.0.1/+test',
+                           '<a href="http://127.0.0.1/+test" rel="external">127.0.0.1/+test</a>'),
+                     array('127.0.0.1/$test',
+                           '<a href="http://127.0.0.1/$test" rel="external">127.0.0.1/$test</a>'),
+                     array('127.0.0.1/\'test',
+                           '<a href="http://127.0.0.1/\'test" rel="external">127.0.0.1/\'test</a>'),
+                     array('127.0.0.1/"test',
+                           '<a href="http://127.0.0.1/&quot;test" rel="external">127.0.0.1/&quot;test</a>'),
+                     array('127.0.0.1/-test',
+                           '<a href="http://127.0.0.1/-test" rel="external">127.0.0.1/-test</a>'),
+                     array('127.0.0.1/_test',
+                           '<a href="http://127.0.0.1/_test" rel="external">127.0.0.1/_test</a>'),
+                     array('127.0.0.1/!test',
+                           '<a href="http://127.0.0.1/!test" rel="external">127.0.0.1/!test</a>'),
+                     array('127.0.0.1/*test',
+                           '<a href="http://127.0.0.1/*test" rel="external">127.0.0.1/*test</a>'),
+                     array('127.0.0.1/test%20stuff',
+                           '<a href="http://127.0.0.1/test%20stuff" rel="external">127.0.0.1/test%20stuff</a>'),
+                     array('http://[::1]:99/test.php',
+                           '<a href="http://[::1]:99/test.php" rel="external">http://[::1]:99/test.php</a>'),
                      array('http://::1/test.php',
                            '<a href="http://::1/test.php" rel="external">http://::1/test.php</a>'),
                      array('http://::1',
                            '<a href="http://::1/" rel="external">http://::1</a>'),
                      array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
                            '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php</a>'),
+                     array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
+                           '<a href="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" rel="external">[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php</a>'),
                      array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
                            '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab</a>'),
                      array('http://127.0.0.1',
@@ -145,14 +177,13 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
                            '&lt;<a href="http://example.com/" rel="external">http://example.com</a>&gt;'),
                      array('http://example.com/path/(foo)/bar',
                            '<a href="http://example.com/path/(foo)/bar" rel="external">http://example.com/path/(foo)/bar</a>'),
-                     //Not a valid url - urls cannot contain unencoded square brackets
                      array('http://example.com/path/[foo]/bar',
                            '<a href="http://example.com/path/[foo]/bar" rel="external">http://example.com/path/[foo]/bar</a>'),
                      array('http://example.com/path/foo/(bar)',
                            '<a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>'),
                      //Not a valid url - urls cannot contain unencoded square brackets
-                     //array('http://example.com/path/foo/[bar]',
-                     //      '<a href="http://example.com/path/foo/[bar]" rel="external">http://example.com/path/foo/[bar]</a>'),
+                     array('http://example.com/path/foo/[bar]',
+                           '<a href="http://example.com/path/foo/[bar]" rel="external">http://example.com/path/foo/[bar]</a>'),
                      array('Hey, check out my cool site http://example.com okay?',
                            'Hey, check out my cool site <a href="http://example.com/" rel="external">http://example.com</a> okay?'),
                      array('What about parens (e.g. http://example.com/path/foo/(bar))?',