Make WordPress Core

Ticket #5081: wptests-[170]-for-[5081].diff

File wptests-[170]-for-[5081].diff, 2.7 KB (added by neodude, 16 years ago)

Test cases; diff against revision 170 at http://svn.automattic.com/wordpress-tests/

  • wp-testcase/test_includes_formatting.php

     
    3737               
    3838        }
    3939       
    40                
     40        // tests that make_clickable will not link trailing periods, commas and
     41        // (semi-)colons in URLs with protocol (i.e. http://wordpress.org)
     42        function test_strip_trailing_with_protocol() {
     43                $urls_before = array(
     44                        'http://wordpress.org/hello.html',
     45                        'There was a spoon named http://wordpress.org. Alice!',
     46                        'There was a spoon named http://wordpress.org, said Alice.',
     47                        'There was a spoon named http://wordpress.org; said Alice.',
     48                        'There was a spoon named http://wordpress.org: said Alice.'
     49                        );
     50                $urls_expected = array(
     51                        '<a href="http://wordpress.org/hello.html" rel="nofollow">http://wordpress.org/hello.html</a>',
     52                        'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>. Alice!',
     53                        'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>, said Alice.',
     54                        'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>; said Alice.',
     55                        'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>: said Alice.'
     56                        );
     57
     58                foreach ($urls_before as $key => $url) {
     59                        $this->assertEquals($urls_expected[$key], make_clickable($url));
     60                }
     61        }
     62
     63        // tests that make_clickable will not link trailing periods, commas and
     64        // (semi-)colons in URLs without protocol (i.e. www.wordpress.org)
     65        function test_strip_trailing_without_protocol() {
     66                $urls_before = array(
     67                        'www.wordpress.org',
     68                        'There was a spoon named www.wordpress.org. Alice!',
     69                        'There was a spoon named www.wordpress.org, said Alice.',
     70                        'There was a spoon named www.wordpress.org; said Alice.',
     71                        'There was a spoon named www.wordpress.org: said Alice.'
     72                        );
     73                $urls_expected = array(
     74                        '<a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>',
     75                        'There was a spoon named <a href="http://www.wordpress.org." rel="nofollow">http://www.wordpress.org.</a> Alice!',
     76                        'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>, said Alice.',
     77                        'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>; said Alice.',
     78                        'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>: said Alice.'
     79                        );
     80
     81                foreach ($urls_before as $key => $url) {
     82                        $this->assertEquals($urls_expected[$key], make_clickable($url));
     83                }
     84        }
     85
    4186}
    4287
    4388class TestJSEscape extends WPTestCase {