Changeset 45505 for trunk/tests/phpunit/tests/formatting/WPTrimWords.php
- Timestamp:
- 06/08/2019 06:41:08 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/WPTrimWords.php
r42343 r45505 5 5 */ 6 6 class Tests_Formatting_WPTrimWords extends WP_UnitTestCase { 7 8 /** 9 * Long Dummy Text. 10 * 11 * @since 5.0.0 12 * 13 * @var string $long_text 14 */ 7 15 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.'; 8 16 … … 43 51 $this->assertEquals( $text, wp_trim_words( $text ) ); 44 52 } 53 54 /** 55 * @ticket 44541 56 */ 57 function test_trims_to_20_counted_by_chars() { 58 switch_to_locale( 'ja_JP' ); 59 $expected = substr( $this->long_text, 0, 20 ) . '…'; 60 $actual = wp_trim_words( $this->long_text, 20 ); 61 restore_previous_locale(); 62 $this->assertEquals( $expected, $actual ); 63 } 64 65 /** 66 * @ticket 44541 67 */ 68 function test_trims_to_20_counted_by_chars_with_double_width_chars() { 69 switch_to_locale( 'ja_JP' ); 70 $text = str_repeat( 'あ', 100 ); 71 $expected = str_repeat( 'あ', 19 ) . '…'; 72 $actual = wp_trim_words( $text, 19 ); 73 restore_previous_locale(); 74 $this->assertEquals( $expected, $actual ); 75 } 45 76 }
Note: See TracChangeset
for help on using the changeset viewer.