| @@ 737-764 (lines=28) @@ | ||
| 734 | /** |
|
| 735 | * Test that a sentence which is too long for a single tweet is split into two tweets, at a word break. |
|
| 736 | */ |
|
| 737 | public function test_long_sentence() { |
|
| 738 | $test_content = 'This is 22 characters '; |
|
| 739 | $blocks = array( |
|
| 740 | $this->generateParagraphData( str_repeat( $test_content, 13 ) ), |
|
| 741 | ); |
|
| 742 | ||
| 743 | $expected_text = array( |
|
| 744 | str_repeat( $test_content, 12 ) . 'This is 22β¦', |
|
| 745 | 'β¦characters', |
|
| 746 | ); |
|
| 747 | ||
| 748 | $expected_boundaries = array( |
|
| 749 | $this->generateNormalBoundary( 274, 275, 'content' ), |
|
| 750 | false, |
|
| 751 | ); |
|
| 752 | ||
| 753 | $expected_blocks = array( |
|
| 754 | $blocks, |
|
| 755 | $blocks, |
|
| 756 | ); |
|
| 757 | ||
| 758 | $this->assertTweetGenerated( |
|
| 759 | $blocks, |
|
| 760 | $expected_text, |
|
| 761 | $expected_boundaries, |
|
| 762 | $expected_blocks |
|
| 763 | ); |
|
| 764 | } |
|
| 765 | ||
| 766 | /** |
|
| 767 | * Test that other space characters will be used when splitting sentences up into words. |
|
| @@ 959-987 (lines=29) @@ | ||
| 956 | /** |
|
| 957 | * Test that a list which is too long for a single tweet is split at the end of a list line. |
|
| 958 | */ |
|
| 959 | public function test_long_list() { |
|
| 960 | $test_content = 'This is 22 characters.'; |
|
| 961 | ||
| 962 | $blocks = array( |
|
| 963 | $this->generateListData( str_repeat( "<li>$test_content</li>", 12 ) ), |
|
| 964 | ); |
|
| 965 | ||
| 966 | $expected_text = array( |
|
| 967 | trim( str_repeat( "- $test_content\n", 11 ) ), |
|
| 968 | "- $test_content", |
|
| 969 | ); |
|
| 970 | ||
| 971 | $expected_boundaries = array( |
|
| 972 | $this->generateLineBoundary( 10, 'values' ), |
|
| 973 | false, |
|
| 974 | ); |
|
| 975 | ||
| 976 | $expected_blocks = array( |
|
| 977 | $blocks, |
|
| 978 | $blocks, |
|
| 979 | ); |
|
| 980 | ||
| 981 | $this->assertTweetGenerated( |
|
| 982 | $blocks, |
|
| 983 | $expected_text, |
|
| 984 | $expected_boundaries, |
|
| 985 | $expected_blocks |
|
| 986 | ); |
|
| 987 | } |
|
| 988 | ||
| 989 | /** |
|
| 990 | * Test that a long list will start a new tweet when it's too long to be appended to the previous |
|
| @@ 1030-1058 (lines=29) @@ | ||
| 1027 | /** |
|
| 1028 | * Test that a range of emoji (including a variety of compound emoji) count as two characters. |
|
| 1029 | */ |
|
| 1030 | public function test_emoji_count_as_two_characters() { |
|
| 1031 | $test_content = 'π π³οΈβπ π©βπ©βπ§βπ§ π¨πΎβπ¦° π©π»βπ» '; |
|
| 1032 | ||
| 1033 | $blocks = array( |
|
| 1034 | $this->generateParagraphData( str_repeat( $test_content, 19 ) ), |
|
| 1035 | ); |
|
| 1036 | ||
| 1037 | $expected_text = array( |
|
| 1038 | trim( str_repeat( $test_content, 18 ) ) . ' π π³οΈβπ π©βπ©βπ§βπ§β¦', |
|
| 1039 | 'β¦π¨πΎβπ¦° π©π»βπ»', |
|
| 1040 | ); |
|
| 1041 | ||
| 1042 | $expected_boundaries = array( |
|
| 1043 | $this->generateNormalBoundary( 705, 706, 'content' ), |
|
| 1044 | false, |
|
| 1045 | ); |
|
| 1046 | ||
| 1047 | $expected_blocks = array( |
|
| 1048 | $blocks, |
|
| 1049 | $blocks, |
|
| 1050 | ); |
|
| 1051 | ||
| 1052 | $this->assertTweetGenerated( |
|
| 1053 | $blocks, |
|
| 1054 | $expected_text, |
|
| 1055 | $expected_boundaries, |
|
| 1056 | $expected_blocks |
|
| 1057 | ); |
|
| 1058 | } |
|
| 1059 | ||
| 1060 | /** |
|
| 1061 | * Test that inline images don't show up in the tweet. |
|
| @@ 2089-2107 (lines=19) @@ | ||
| 2086 | /** |
|
| 2087 | * Test that long URLs don't cause text to break into multiple tweets. |
|
| 2088 | */ |
|
| 2089 | public function test_long_links_dont_break_a_paragraph_up() { |
|
| 2090 | $test_url = 'https://jetpack.com/' . str_repeat( 'a', 280 ); |
|
| 2091 | ||
| 2092 | $test_content = "It's <a href='$test_url'>a celebration</a>!"; |
|
| 2093 | $expected_text = "It's a celebration ($test_url)!"; |
|
| 2094 | ||
| 2095 | $blocks = array( |
|
| 2096 | $this->generateParagraphData( $test_content ), |
|
| 2097 | ); |
|
| 2098 | ||
| 2099 | $expected_content = array( |
|
| 2100 | array( |
|
| 2101 | 'text' => $expected_text, |
|
| 2102 | 'urls' => array( $test_url ), |
|
| 2103 | ), |
|
| 2104 | ); |
|
| 2105 | ||
| 2106 | $this->assertTweetGenerated( $blocks, $expected_content, array( false ), array( $blocks ) ); |
|
| 2107 | } |
|
| 2108 | ||
| 2109 | /** |
|
| 2110 | * Test that URLs appearing before and after paragraph breaks are counted correctly. |
|