| @@ 754-781 (lines=28) @@ | ||
| 751 | /** |
|
| 752 | * Test that a sentence which is too long for a single tweet is split into two tweets, at a word break. |
|
| 753 | */ |
|
| 754 | public function test_long_sentence() { |
|
| 755 | $test_content = 'This is 22 characters '; |
|
| 756 | $blocks = array( |
|
| 757 | $this->generateParagraphData( str_repeat( $test_content, 13 ) ), |
|
| 758 | ); |
|
| 759 | ||
| 760 | $expected_text = array( |
|
| 761 | str_repeat( $test_content, 12 ) . 'This is 22β¦', |
|
| 762 | 'β¦characters', |
|
| 763 | ); |
|
| 764 | ||
| 765 | $expected_boundaries = array( |
|
| 766 | $this->generateNormalBoundary( 274, 275, 'content' ), |
|
| 767 | false, |
|
| 768 | ); |
|
| 769 | ||
| 770 | $expected_blocks = array( |
|
| 771 | $blocks, |
|
| 772 | $blocks, |
|
| 773 | ); |
|
| 774 | ||
| 775 | $this->assertTweetGenerated( |
|
| 776 | $blocks, |
|
| 777 | $expected_text, |
|
| 778 | $expected_boundaries, |
|
| 779 | $expected_blocks |
|
| 780 | ); |
|
| 781 | } |
|
| 782 | ||
| 783 | /** |
|
| 784 | * Test that other space characters will be used when splitting sentences up into words. |
|
| @@ 976-1004 (lines=29) @@ | ||
| 973 | /** |
|
| 974 | * Test that a list which is too long for a single tweet is split at the end of a list line. |
|
| 975 | */ |
|
| 976 | public function test_long_list() { |
|
| 977 | $test_content = 'This is 22 characters.'; |
|
| 978 | ||
| 979 | $blocks = array( |
|
| 980 | $this->generateListData( str_repeat( "<li>$test_content</li>", 12 ) ), |
|
| 981 | ); |
|
| 982 | ||
| 983 | $expected_text = array( |
|
| 984 | trim( str_repeat( "- $test_content\n", 11 ) ), |
|
| 985 | "- $test_content", |
|
| 986 | ); |
|
| 987 | ||
| 988 | $expected_boundaries = array( |
|
| 989 | $this->generateLineBoundary( 10, 'values' ), |
|
| 990 | false, |
|
| 991 | ); |
|
| 992 | ||
| 993 | $expected_blocks = array( |
|
| 994 | $blocks, |
|
| 995 | $blocks, |
|
| 996 | ); |
|
| 997 | ||
| 998 | $this->assertTweetGenerated( |
|
| 999 | $blocks, |
|
| 1000 | $expected_text, |
|
| 1001 | $expected_boundaries, |
|
| 1002 | $expected_blocks |
|
| 1003 | ); |
|
| 1004 | } |
|
| 1005 | ||
| 1006 | /** |
|
| 1007 | * Test that a long list will start a new tweet when it's too long to be appended to the previous |
|
| @@ 1047-1075 (lines=29) @@ | ||
| 1044 | /** |
|
| 1045 | * Test that a range of emoji (including a variety of compound emoji) count as two characters. |
|
| 1046 | */ |
|
| 1047 | public function test_emoji_count_as_two_characters() { |
|
| 1048 | $test_content = 'π π³οΈβπ π©βπ©βπ§βπ§ π¨πΎβπ¦° π©π»βπ» '; |
|
| 1049 | ||
| 1050 | $blocks = array( |
|
| 1051 | $this->generateParagraphData( str_repeat( $test_content, 19 ) ), |
|
| 1052 | ); |
|
| 1053 | ||
| 1054 | $expected_text = array( |
|
| 1055 | trim( str_repeat( $test_content, 18 ) ) . ' π π³οΈβπ π©βπ©βπ§βπ§β¦', |
|
| 1056 | 'β¦π¨πΎβπ¦° π©π»βπ»', |
|
| 1057 | ); |
|
| 1058 | ||
| 1059 | $expected_boundaries = array( |
|
| 1060 | $this->generateNormalBoundary( 705, 706, 'content' ), |
|
| 1061 | false, |
|
| 1062 | ); |
|
| 1063 | ||
| 1064 | $expected_blocks = array( |
|
| 1065 | $blocks, |
|
| 1066 | $blocks, |
|
| 1067 | ); |
|
| 1068 | ||
| 1069 | $this->assertTweetGenerated( |
|
| 1070 | $blocks, |
|
| 1071 | $expected_text, |
|
| 1072 | $expected_boundaries, |
|
| 1073 | $expected_blocks |
|
| 1074 | ); |
|
| 1075 | } |
|
| 1076 | ||
| 1077 | /** |
|
| 1078 | * Test that inline images don't show up in the tweet. |
|
| @@ 2106-2124 (lines=19) @@ | ||
| 2103 | /** |
|
| 2104 | * Test that long URLs don't cause text to break into multiple tweets. |
|
| 2105 | */ |
|
| 2106 | public function test_long_links_dont_break_a_paragraph_up() { |
|
| 2107 | $test_url = 'https://jetpack.com/' . str_repeat( 'a', 280 ); |
|
| 2108 | ||
| 2109 | $test_content = "It's <a href='$test_url'>a celebration</a>!"; |
|
| 2110 | $expected_text = "It's a celebration ($test_url)!"; |
|
| 2111 | ||
| 2112 | $blocks = array( |
|
| 2113 | $this->generateParagraphData( $test_content ), |
|
| 2114 | ); |
|
| 2115 | ||
| 2116 | $expected_content = array( |
|
| 2117 | array( |
|
| 2118 | 'text' => $expected_text, |
|
| 2119 | 'urls' => array( $test_url ), |
|
| 2120 | ), |
|
| 2121 | ); |
|
| 2122 | ||
| 2123 | $this->assertTweetGenerated( $blocks, $expected_content, array( false ), array( $blocks ) ); |
|
| 2124 | } |
|
| 2125 | ||
| 2126 | /** |
|
| 2127 | * Test that URLs appearing before and after paragraph breaks are counted correctly. |
|