WordPress.org

Make WordPress Core

Changeset 441 in tests


Ignore:
Timestamp:
09/20/11 17:13:24 (3 years ago)
Author:
duck_
Message:

Add tests for wp_trim_words(). See #WP16372.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_formatting.php

    r438 r441  
    11241124} 
    11251125 
     1126class TestWPTrimWords extends WPTestCase { 
     1127    private $long_text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius lacinia vehicula. Etiam sapien risus, ultricies ac posuere eu, convallis sit amet augue. Pellentesque urna massa, lacinia vel iaculis eget, bibendum in mauris. Aenean eleifend pulvinar ligula, a convallis eros gravida non. Suspendisse potenti. Pellentesque et odio tortor. In vulputate pellentesque libero, sed dapibus velit mollis viverra. Pellentesque id urna euismod dolor cursus sagittis.'; 
     1128 
     1129    function test_trims_to_55_by_default() { 
     1130        $trimmed = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius lacinia vehicula. Etiam sapien risus, ultricies ac posuere eu, convallis sit amet augue. Pellentesque urna massa, lacinia vel iaculis eget, bibendum in mauris. Aenean eleifend pulvinar ligula, a convallis eros gravida non. Suspendisse potenti. Pellentesque et odio tortor. In vulputate pellentesque libero, sed dapibus velit…'; 
     1131        $this->assertEquals( $trimmed, wp_trim_words( $this->long_text ) ); 
     1132    } 
     1133 
     1134    function test_trims_to_10() { 
     1135        $trimmed = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius…'; 
     1136        $this->assertEquals( $trimmed, wp_trim_words( $this->long_text, 10 ) ); 
     1137    } 
     1138 
     1139    function test_trims_to_5_and_uses_custom_more() { 
     1140        $trimmed = 'Lorem ipsum dolor sit amet,[...] Read on!'; 
     1141        $this->assertEquals( $trimmed, wp_trim_words( $this->long_text, 5, '[...] Read on!' ) ); 
     1142    } 
     1143 
     1144    function test_strips_tags_before_trimming() { 
     1145        $text = 'This text contains a <a href="http://wordpress.org"> link </a> to WordPress.org!'; 
     1146        $trimmed = 'This text contains a link&hellip;'; 
     1147        $this->assertEquals( $trimmed, wp_trim_words( $text, 5 ) ); 
     1148    } 
     1149 
     1150    function test_doesnt_trim_short_text() { 
     1151        $text = 'This is some short text.'; 
     1152        $this->assertEquals( $text, wp_trim_words( $text ) ); 
     1153    } 
     1154} 
     1155 
    11261156?> 
Note: See TracChangeset for help on using the changeset viewer.