mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Includes documenting data provider values using hash notation in the tests for: * `convert_smilies()` * `get_url_in_content()` * `links_add_target()` * `normalize_whitespace()` Follow-up to [26191], [26327], [26328], [26972], [55562]. See #57841. git-svn-id: https://develop.svn.wordpress.org/trunk@55563 602fd350-edb4-49c9-b593-d223f7449a82
58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group formatting
|
|
*
|
|
* @covers ::get_url_in_content
|
|
*/
|
|
class Tests_Formatting_GetUrlInContent extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* Tests the get_url_in_content() function.
|
|
*
|
|
* @dataProvider data_get_url_in_content
|
|
*/
|
|
public function test_get_url_in_content( $input, $expected ) {
|
|
$this->assertSame( $expected, get_url_in_content( $input ) );
|
|
}
|
|
|
|
/**
|
|
* Data provider.
|
|
*
|
|
* @return array {
|
|
* @type array {
|
|
* @type string $input Input content.
|
|
* @type string $expected Expected output.
|
|
* }
|
|
* }
|
|
*/
|
|
public function data_get_url_in_content() {
|
|
return array(
|
|
array( // Empty content.
|
|
'',
|
|
false,
|
|
),
|
|
array( // No URLs.
|
|
'<div>NO URL CONTENT</div>',
|
|
false,
|
|
),
|
|
array( // Ignore none link elements.
|
|
'<div href="/relative.php">NO URL CONTENT</div>',
|
|
false,
|
|
),
|
|
array( // Single link.
|
|
'ABC<div><a href="/relative.php">LINK</a> CONTENT</div>',
|
|
'/relative.php',
|
|
),
|
|
array( // Multiple links.
|
|
'ABC<div><a href="/relative.php">LINK</a> CONTENT <a href="/suppress.php">LINK</a></div>',
|
|
'/relative.php',
|
|
),
|
|
array( // Escape link.
|
|
'ABC<div><a href="http://example.com/Mr%20WordPress 2">LINK</a> CONTENT </div>',
|
|
'http://example.com/Mr%20WordPress%202',
|
|
),
|
|
);
|
|
}
|
|
}
|