|
@@ 2044-2066 (lines=23) @@
|
| 2041 |
|
/** |
| 2042 |
|
* Test that link URLs are added to the tweet text. |
| 2043 |
|
*/ |
| 2044 |
|
public function test_links_handled() { |
| 2045 |
|
$test_urls = array( |
| 2046 |
|
'https://jetpack.com', |
| 2047 |
|
'https://WordPress.org/', |
| 2048 |
|
'https://jetpack.com', |
| 2049 |
|
); |
| 2050 |
|
|
| 2051 |
|
$test_content = "This <a href='$test_urls[0]'>is</a> <a href='$test_urls[1]'>a</a> <a href='$test_urls[2]'>test</a>."; |
| 2052 |
|
$expected_text = "This is ($test_urls[0]) a ($test_urls[1]) test ($test_urls[2])."; |
| 2053 |
|
|
| 2054 |
|
$blocks = array( |
| 2055 |
|
$this->generateParagraphData( $test_content ), |
| 2056 |
|
); |
| 2057 |
|
|
| 2058 |
|
$expected_content = array( |
| 2059 |
|
array( |
| 2060 |
|
'text' => $expected_text, |
| 2061 |
|
'urls' => $test_urls, |
| 2062 |
|
), |
| 2063 |
|
); |
| 2064 |
|
|
| 2065 |
|
$this->assertTweetGenerated( $blocks, $expected_content, array( false ), array( $blocks ) ); |
| 2066 |
|
} |
| 2067 |
|
|
| 2068 |
|
/** |
| 2069 |
|
* Test that unsupported URL formats in links are ignored. |
|
@@ 2308-2339 (lines=32) @@
|
| 2305 |
|
/** |
| 2306 |
|
* If the text of the link is the same as the href, we should only include one in the tweet. |
| 2307 |
|
*/ |
| 2308 |
|
public function test_text_urls_inside_links_are_deduplicated() { |
| 2309 |
|
$test_urls = array( |
| 2310 |
|
'https://jetpack.com', |
| 2311 |
|
'https://wordpress.org/', |
| 2312 |
|
); |
| 2313 |
|
|
| 2314 |
|
$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>."; |
| 2315 |
|
|
| 2316 |
|
$blocks = array( |
| 2317 |
|
$this->generateParagraphData( $test_content ), |
| 2318 |
|
); |
| 2319 |
|
|
| 2320 |
|
$expected_content = array( |
| 2321 |
|
array( |
| 2322 |
|
'text' => "Visiting $test_urls[0] is good, so is visiting WordPress.org.", |
| 2323 |
|
'urls' => array( |
| 2324 |
|
$test_urls[0], |
| 2325 |
|
'WordPress.org', |
| 2326 |
|
), |
| 2327 |
|
), |
| 2328 |
|
); |
| 2329 |
|
|
| 2330 |
|
$expected_boundaries = array( |
| 2331 |
|
false, |
| 2332 |
|
); |
| 2333 |
|
|
| 2334 |
|
$expected_blocks = array( |
| 2335 |
|
$blocks, |
| 2336 |
|
); |
| 2337 |
|
|
| 2338 |
|
$this->assertTweetGenerated( $blocks, $expected_content, $expected_boundaries, $expected_blocks ); |
| 2339 |
|
} |
| 2340 |
|
|
| 2341 |
|
/** |
| 2342 |
|
* Test that a single Twitter card generates correctly. |