- Timestamp:
- 12/12/2019 05:51:35 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/WPTargetedLinkRel.php
r46586 r46894 39 39 public function test_rel_with_single_quote_delimiter() { 40 40 $content = '<p>Links: <a href="/" rel=\'existing values\' target="_blank">Existing rel</a></p>'; 41 $expected = '<p>Links: <a href="/" rel= \'existing values noopener noreferrer\'target="_blank">Existing rel</a></p>';41 $expected = '<p>Links: <a href="/" rel="existing values noopener noreferrer" target="_blank">Existing rel</a></p>'; 42 42 $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); 43 43 } … … 52 52 $content = '<p>Links: <a href="/" rel = existing target="_blank">Existing rel</a></p>'; 53 53 $expected = '<p>Links: <a href="/" rel="existing noopener noreferrer" target="_blank">Existing rel</a></p>'; 54 $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );55 }56 57 public function test_rel_value_spaced_and_no_delimiter_and_values_to_escape() {58 $content = '<p>Links: <a href="/" rel = existing"value target="_blank">Existing rel</a></p>';59 $expected = '<p>Links: <a href="/" rel="existing"value noopener noreferrer" target="_blank">Existing rel</a></p>';60 54 $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); 61 55 } … … 115 109 116 110 /** 117 * Ensure correct quotes are used when relation attribute (rel) is missing.111 * Ensure the content of style and script tags are not processed 118 112 * 119 113 * @ticket 47244 120 114 */ 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>'; 115 public function test_wp_targeted_link_rel_skips_style_and_scripts() { 116 $content = '<style><a href="/" target=a></style><p>Links: <script>console.log("<a href=\'/\' target=a>hi</a>");</script><script>alert(1);</script>here <a href="/" target=_blank>aq</a></p><script>console.log("<a href=\'last\' target=\'_blank\'")</script>'; 117 $expected = '<style><a href="/" target=a></style><p>Links: <script>console.log("<a href=\'/\' target=a>hi</a>");</script><script>alert(1);</script>here <a href="/" target="_blank" rel="noopener noreferrer">aq</a></p><script>console.log("<a href=\'last\' target=\'_blank\'")</script>'; 128 118 $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); 129 119 } … … 140 130 } 141 131 132 public function test_wp_targeted_link_rel_tab_separated_values_are_split() { 133 $content = "<p>Links: <a href=\"/\" target=\"_blank\" rel=\"ugc\t\tnoopener\t\">No rel</a></p>"; 134 $expected = '<p>Links: <a href="/" target="_blank" rel="ugc noopener noreferrer">No rel</a></p>'; 135 $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); 136 } 137 142 138 }
Note: See TracChangeset
for help on using the changeset viewer.