| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @group formatting |
| 5 | */ |
| 6 | class Tests_Rel_Nofollow extends WP_UnitTestCase { |
| 7 | /** |
| 8 | * @ticket 11360 |
| 9 | * @dataProvider data_wp_rel_nofollow |
| 10 | */ |
| 11 | public function test_wp_rel_nofollow( $input, $output ) { |
| 12 | return $this->assertEquals( wp_slash( $output ), wp_rel_nofollow( $input ) ); |
| 13 | } |
| 14 | |
| 15 | public function data_wp_rel_nofollow() { |
| 16 | $home_url_http = set_url_scheme( home_url(), 'http' ); |
| 17 | $home_url_https = set_url_scheme( home_url(), 'https' ); |
| 18 | |
| 19 | return array( |
| 20 | array( |
| 21 | '<a href="https://wordpress.org">Double Quotes</a>', |
| 22 | '<a href="https://wordpress.org" rel="nofollow">Double Quotes</a>', |
| 23 | ), |
| 24 | array( |
| 25 | "<a href='https://wordpress.org'>Single Quotes</a>", |
| 26 | "<a href='https://wordpress.org' rel=\"nofollow\">Single Quotes</a>", |
| 27 | ), |
| 28 | array( |
| 29 | '<a href="https://wordpress.org" title="Title">Multiple attributes</a>', |
| 30 | '<a href="https://wordpress.org" title="Title" rel="nofollow">Multiple attributes</a>', |
| 31 | ), |
| 32 | array( |
| 33 | '<a title="Title" href="https://wordpress.org">Multiple attributes</a>', |
| 34 | '<a title="Title" href="https://wordpress.org" rel="nofollow">Multiple attributes</a>', |
| 35 | ), |
| 36 | array( |
| 37 | '<a data-someflag href="https://wordpress.org">Multiple attributes</a>', |
| 38 | '<a data-someflag href="https://wordpress.org" rel="nofollow">Multiple attributes</a>', |
| 39 | ), |
| 40 | array( |
| 41 | '<a data-someflag title="Title" href="https://wordpress.org" onclick="" >Everything at once</a>', |
| 42 | '<a data-someflag title="Title" href="https://wordpress.org" onclick="" rel="nofollow">Everything at once</a>', |
| 43 | ), |
| 44 | array( |
| 45 | '<a href="' . $home_url_http . '/some-url">Home URL (http)</a>', |
| 46 | '<a href="' . $home_url_http . '/some-url">Home URL (http)</a>', |
| 47 | ), |
| 48 | array( |
| 49 | '<a href="' . $home_url_https . '/some-url">Home URL (https)</a>', |
| 50 | '<a href="' . $home_url_https . '/some-url">Home URL (https)</a>', |
| 51 | ), |
| 52 | ); |
| 53 | } |
| 54 | } |