1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * @group formatting |
---|
5 | */ |
---|
6 | class Tests_Formatting_GetUrlInContent extends WP_UnitTestCase { |
---|
7 | |
---|
8 | /** |
---|
9 | * URL Content DataProvider |
---|
10 | * |
---|
11 | * array ( input_txt, converted_output_txt) |
---|
12 | */ |
---|
13 | public function get_input_output() { |
---|
14 | return array ( |
---|
15 | array ( |
---|
16 | "", |
---|
17 | false |
---|
18 | ), //empty content |
---|
19 | array ( |
---|
20 | "<div>NO URL CONTENT</div>", |
---|
21 | false |
---|
22 | ), //no URLs |
---|
23 | array ( |
---|
24 | '<div href="/relative.php">NO URL CONTENT</div>', |
---|
25 | false |
---|
26 | ), // ignore none link elements |
---|
27 | array ( |
---|
28 | 'ABC<div><a href="/relative.php">LINK</a> CONTENT</div>', |
---|
29 | "/relative.php" |
---|
30 | ), // single link |
---|
31 | array ( |
---|
32 | 'ABC<div><a href="/relative.php">LINK</a> CONTENT <a href="/suppress.php">LINK</a></div>', |
---|
33 | "/relative.php" |
---|
34 | ), // multiple links |
---|
35 | array ( |
---|
36 | 'ABC<div><a href="http://example.com/Mr%20WordPress 2">LINK</a> CONTENT </div>', |
---|
37 | "http://example.com/Mr%20WordPress2" |
---|
38 | ), // escape link |
---|
39 | ); |
---|
40 | } |
---|
41 | |
---|
42 | /** |
---|
43 | * Validate the get_url_in_content function |
---|
44 | * @dataProvider get_input_output |
---|
45 | */ |
---|
46 | function test_get_url_in_content( $in_str, $exp_str ) { |
---|
47 | |
---|
48 | $this->assertEquals($exp_str, get_url_in_content( $in_str ) ); |
---|
49 | |
---|
50 | } |
---|
51 | } |
---|