| 104 | |
| 105 | /** |
| 106 | * Ensure JSON format is preserved when relation attribute (rel) is missing. |
| 107 | * |
| 108 | * @ticket 46316 |
| 109 | */ |
| 110 | public function test_wp_targeted_link_rel_should_preserve_json() { |
| 111 | $content = '<p>Links: <a href=\"\/\" target=\"_blank\">No rel<\/a><\/p>'; |
| 112 | $expected = '<p>Links: <a href=\"\/\" target=\"_blank\" rel=\"noopener noreferrer\">No rel<\/a><\/p>'; |
| 113 | $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Ensure correct quotes are used when relation attribute (rel) is missing. |
| 118 | * |
| 119 | * @ticket 47244 |
| 120 | */ |
| 121 | public function test_wp_targeted_link_rel_should_use_correct_quotes() { |
| 122 | $content = '<p>Links: <a href=\'\/\' target=\'_blank\'>No rel<\/a><\/p>'; |
| 123 | $expected = '<p>Links: <a href=\'\/\' target=\'_blank\' rel=\'noopener noreferrer\'>No rel<\/a><\/p>'; |
| 124 | $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); |
| 125 | |
| 126 | $content = '<p>Links: <a href=\'\/\' target=_blank>No rel<\/a><\/p>'; |
| 127 | $expected = '<p>Links: <a href=\'\/\' target=_blank rel=\'noopener noreferrer\'>No rel<\/a><\/p>'; |
| 128 | $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); |
| 129 | } |