WordPress.org

Make WordPress Core

Changeset 1330 in tests


Ignore:
Timestamp:
07/30/2013 08:25:36 AM (8 years ago)
Author:
ryan
Message:

Update test_get_url_in_content() to reflect changes in get_url_in_content().

see #23570

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/post/formats.php

    r1312 r1330  
    106106$commentary
    107107DATA;
     108        $href = '<a href="http://nytimes.com">NYT</a>';
     109        $href_with_commentary =<<<DATA
     110$href
    108111
     112$commentary
     113DATA;
    109114        $link_post_id = $this->factory->post->create( array( 'post_content' => $link ) );
    110115        $content_link = get_url_in_content( get_post_field( 'post_content', $link_post_id ) );
    111         $this->assertEquals( $content_link, $link );
     116        $this->assertEquals( false, $content_link );
    112117
    113118        $link_with_post_id = $this->factory->post->create( array( 'post_content' => $link_with_commentary ) );
    114119        $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) );
    115         $this->assertEquals( $content_link, $link );
     120        $this->assertEquals( false, $content_link );
    116121
    117122        $content_link = get_url_in_content( get_post_field( 'post_content', $link_post_id ) );
    118         $this->assertEquals( $content_link, $link );
     123        $this->assertEquals( false, $content_link );
    119124
    120125        $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) );
    121         $this->assertEquals( $content_link, $link );
     126        $this->assertEquals( false, $content_link );
    122127
    123128        $empty_post_id = $this->factory->post->create( array( 'post_content' => '' ) );
    124129        $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) );
    125         $this->assertEquals( $content_link, '' );
     130        $this->assertEquals( false, $content_link );
    126131
    127132        $comm_post_id = $this->factory->post->create( array( 'post_content' => $commentary ) );
    128         update_post_meta( $comm_post_id, '_format_url', $link );
    129133        $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) );
    130         $this->assertEquals( $content_link, '' );
     134        $this->assertEquals( false, $content_link );
     135
     136        // Now with an href
     137        $href_post_id = $this->factory->post->create( array( 'post_content' => $href ) );
     138        $content_link = get_url_in_content( get_post_field( 'post_content', $href_post_id ) );
     139        $this->assertEquals( $link, $content_link );
     140
     141        $href_with_post_id = $this->factory->post->create( array( 'post_content' => $href_with_commentary ) );
     142        $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) );
     143        $this->assertEquals( $link, $content_link );
     144
     145        $content_link = get_url_in_content( get_post_field( 'post_content', $href_post_id ) );
     146        $this->assertEquals( $link, $content_link );
     147
     148        $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) );
     149        $this->assertEquals( $link, $content_link );
     150
     151        $empty_post_id = $this->factory->post->create( array( 'post_content' => '' ) );
     152        $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) );
     153        $this->assertEquals( false, $content_link );
     154
     155        $comm_post_id = $this->factory->post->create( array( 'post_content' => $commentary ) );
     156        $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) );
     157        $this->assertEquals( false, $content_link );
    131158    }
    132159}
Note: See TracChangeset for help on using the changeset viewer.