WordPress.org

Make WordPress Core

Changeset 667 in tests


Ignore:
Timestamp:
04/11/2012 09:15:48 PM (6 years ago)
Author:
ryan
Message:

Attribute and segfault tests for make_clickable(). Props duck_

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_formatting.php

    r663 r667  
    218218    }
    219219
     220    function test_wrapped_in_angles() {
     221        $before = array(
     222            'URL wrapped in angle brackets <http://example.com/>',
     223            'URL wrapped in angle brackets with padding < http://example.com/ >',
     224            'mailto wrapped in angle brackets <foo@example.com>',
     225        );
     226        $expected = array(
     227            'URL wrapped in angle brackets <<a href="http://example.com/" rel="nofollow">http://example.com/</a>>',
     228            'URL wrapped in angle brackets with padding < <a href="http://example.com/" rel="nofollow">http://example.com/</a> >',
     229            'mailto wrapped in angle brackets <foo@example.com>',
     230        );
     231        foreach ($before as $key => $url) {
     232            $this->assertEquals($expected[$key], make_clickable($url));
     233        }
     234    }
     235
    220236    function test_preceded_by_punctuation() {
    221237        $before = array(
     
    226242            'Exclamation mark then URL!http://example.com/',
    227243            'Question mark then URL?http://example.com/',
    228             'URL wrapped in angle brackets <http://example.com/>',
    229244        );
    230245        $expected = array(
     
    235250            'Exclamation mark then URL!<a href="http://example.com/" rel="nofollow">http://example.com/</a>',
    236251            'Question mark then URL?<a href="http://example.com/" rel="nofollow">http://example.com/</a>',
    237             'URL wrapped in angle brackets <<a href="http://example.com/" rel="nofollow">http://example.com/</a>>',
    238252        );
    239253        foreach ($before as $key => $url) {
     
    250264            (<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>)",
    251265            "<span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' /> <param name='allowfullscreen' value='true' /> <param name='wmode' value='opaque' /> <embed src='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='opaque'></embed> </object></span>",
     266            '<a href="http://example.com/example.gif" title="Image from http://example.com">Look at this image!</a>',
    252267        );
    253268        $urls_expected = array(
     
    258273            (<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>)",
    259274            "<span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' /> <param name='allowfullscreen' value='true' /> <param name='wmode' value='opaque' /> <embed src='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='opaque'></embed> </object></span>",
     275            '<a href="http://example.com/example.gif" title="Image from http://example.com">Look at this image!</a>',
    260276        );
    261277        foreach ($urls_before as $key => $url) {
     
    277293            $this->assertEquals( $urls_expected[$key], make_clickable( $url ) );
    278294        }
     295    }
     296
     297    function test_no_links_within_links() {
     298        $in = array(
     299            'Some text with a link <a href="http://example.com">http://example.com</a>',
     300            //'<a href="http://wordpress.org">This is already a link www.wordpress.org</a>', // fails in 3.3.1 too
     301        );
     302        foreach ( $in as $text ) {
     303            $this->assertEquals( $text, make_clickable( $text ) );
     304        }
     305    }
     306
     307    /**
     308     * @ticket 16892
     309     */
     310    function test_no_segfault() {
     311        if ( version_compare( $GLOBALS['wp_version'], '3.1.1', '<' ) )
     312            $this->markTestSkipped();
     313
     314        $in = str_repeat( 'http://example.com/2011/03/18/post-title/', 256 );
     315        $out = make_clickable( $in );
     316        if ( version_compare( $GLOBALS['wp_version'], '3.4-alpha', '>=' ) )
     317            $this->assertEquals( $in, $out );
    279318    }
    280319}
Note: See TracChangeset for help on using the changeset viewer.