@@ 2027-2049 (lines=23) @@ | ||
2024 | /** |
|
2025 | * Test that link URLs are added to the tweet text. |
|
2026 | */ |
|
2027 | public function test_links_handled() { |
|
2028 | $test_urls = array( |
|
2029 | 'https://jetpack.com', |
|
2030 | 'https://WordPress.org/', |
|
2031 | 'https://jetpack.com', |
|
2032 | ); |
|
2033 | ||
2034 | $test_content = "This <a href='$test_urls[0]'>is</a> <a href='$test_urls[1]'>a</a> <a href='$test_urls[2]'>test</a>."; |
|
2035 | $expected_text = "This is ($test_urls[0]) a ($test_urls[1]) test ($test_urls[2])."; |
|
2036 | ||
2037 | $blocks = array( |
|
2038 | $this->generateParagraphData( $test_content ), |
|
2039 | ); |
|
2040 | ||
2041 | $expected_content = array( |
|
2042 | array( |
|
2043 | 'text' => $expected_text, |
|
2044 | 'urls' => $test_urls, |
|
2045 | ), |
|
2046 | ); |
|
2047 | ||
2048 | $this->assertTweetGenerated( $blocks, $expected_content, array( false ), array( $blocks ) ); |
|
2049 | } |
|
2050 | ||
2051 | /** |
|
2052 | * Test that unsupported URL formats in links are ignored. |
|
@@ 2291-2322 (lines=32) @@ | ||
2288 | /** |
|
2289 | * If the text of the link is the same as the href, we should only include one in the tweet. |
|
2290 | */ |
|
2291 | public function test_text_urls_inside_links_are_deduplicated() { |
|
2292 | $test_urls = array( |
|
2293 | 'https://jetpack.com', |
|
2294 | 'https://wordpress.org/', |
|
2295 | ); |
|
2296 | ||
2297 | $test_content = "Visiting <a href='$test_urls[0]'>$test_urls[0]</a> is good, so is visiting <a href='$test_urls[1]'>WordPress.org</a>."; |
|
2298 | ||
2299 | $blocks = array( |
|
2300 | $this->generateParagraphData( $test_content ), |
|
2301 | ); |
|
2302 | ||
2303 | $expected_content = array( |
|
2304 | array( |
|
2305 | 'text' => "Visiting $test_urls[0] is good, so is visiting WordPress.org.", |
|
2306 | 'urls' => array( |
|
2307 | $test_urls[0], |
|
2308 | 'WordPress.org', |
|
2309 | ), |
|
2310 | ), |
|
2311 | ); |
|
2312 | ||
2313 | $expected_boundaries = array( |
|
2314 | false, |
|
2315 | ); |
|
2316 | ||
2317 | $expected_blocks = array( |
|
2318 | $blocks, |
|
2319 | ); |
|
2320 | ||
2321 | $this->assertTweetGenerated( $blocks, $expected_content, $expected_boundaries, $expected_blocks ); |
|
2322 | } |
|
2323 | ||
2324 | /** |
|
2325 | * Test that a single Twitter card generates correctly. |