87 | | //$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”, and a comma.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>", and a comma.')); |
88 | | //$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”; and a semi-colon.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"; and a semi-colon.')); |
89 | | //$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”- and a dash.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"- and a dash.')); |
90 | | //$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”… and ellipses.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"... and ellipses.')); |
91 | | //$this->assertEquals('Here is “a test <a href="http://example.com">with a link</a>”.', wptexturize('Here is "a test <a href="http://example.com">with a link</a>".')); |
92 | | //$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”and a work stuck to the end.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"and a work stuck to the end.')); |
| 87 | $this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”, and a comma.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>", and a comma.')); |
| 88 | $this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”; and a semi-colon.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"; and a semi-colon.')); |
| 89 | $this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”- and a dash.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"- and a dash.')); |
| 90 | $this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”… and ellipses.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"... and ellipses.')); |
| 91 | $this->assertEquals('Here is “a test <a href="http://example.com">with a link</a>”.', wptexturize('Here is "a test <a href="http://example.com">with a link</a>".')); |
| 92 | $this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”and a work stuck to the end.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"and a work stuck to the end.')); |
2051 | | } |
2052 | | No newline at end of file |
| 2056 | |
| 2057 | /** |
| 2058 | * Test that double quotes and apostrophes close correctly in the presence of inline html tags. |
| 2059 | * |
| 2060 | * @ticket 18549 |
| 2061 | * @dataProvider data_inline_end_tags |
| 2062 | */ |
| 2063 | function test_inline_end_tags( $input, $output ) { |
| 2064 | return $this->assertEquals( $output, wptexturize( $input ) ); |
| 2065 | } |
| 2066 | |
| 2067 | function data_inline_end_tags() { |
| 2068 | return array( |
| 2069 | array( |
| 2070 | 'The word is "<a href="http://example.com/">quoted</a>".', |
| 2071 | 'The word is “<a href="http://example.com/">quoted</a>”.', |
| 2072 | ), |
| 2073 | array( |
| 2074 | 'The word is \'<a href="http://example.com/">quoted</a>\'', |
| 2075 | 'The word is ‘<a href="http://example.com/">quoted</a>’', |
| 2076 | ), |
| 2077 | array( |
| 2078 | 'The word is \'<a href="http://example.com/">quoted.</a>\'', |
| 2079 | 'The word is ‘<a href="http://example.com/">quoted.</a>’', |
| 2080 | ), |
| 2081 | array( |
| 2082 | 'The word is \'<a href="http://example.com/">quoted</a>\'.', |
| 2083 | 'The word is ‘<a href="http://example.com/">quoted</a>’.', |
| 2084 | ), |
| 2085 | array( |
| 2086 | 'The word is not \'<a href="http://example.com/">quot</a>\'d', |
| 2087 | 'The word is not ‘<a href="http://example.com/">quot</a>’d', |
| 2088 | ), |
| 2089 | array( |
| 2090 | '<em>John</em>\'s', |
| 2091 | '<em>John</em>’s', |
| 2092 | ), |
| 2093 | array( |
| 2094 | '\'<em>John</em>\'s\'', |
| 2095 | '‘<em>John</em>’s’', |
| 2096 | ), |
| 2097 | array( |
| 2098 | '"<em>John</em>\'s"', |
| 2099 | '“<em>John</em>’s”', |
| 2100 | ), |
| 2101 | array( |
| 2102 | '<em>"John"</em>\'s', |
| 2103 | //'<em>“John”</em>’s', // Should be but... |
| 2104 | '<em>“John”</em>‘s', // Wrong: the ' in the stripped "John"'s seen as an opening single quote. |
| 2105 | ), |
| 2106 | array( |
| 2107 | '<em>\'John\'</em>\'s', |
| 2108 | //'<em>‘John’</em>’s', // Should be but... |
| 2109 | '<em>‘John”</em>s', // Wrong: the '' in the stripped 'John''s seen as a closing double tick quote. |
| 2110 | ), |
| 2111 | array( |
| 2112 | '<strong>Read more: </strong>"<a href="http://blah.com/test">Something (else)</a>"</p>', |
| 2113 | '<strong>Read more: </strong>“<a href="http://blah.com/test">Something (else)</a>”</p>', |
| 2114 | ), |
| 2115 | |
| 2116 | ); |
| 2117 | } |
| 2118 | |
| 2119 | /** |
| 2120 | * Test low-level wptexturize_replace_xxx routines. |
| 2121 | * @ticket wptexturize_replace_xxx |
| 2122 | */ |
| 2123 | function test_wptexturize_replace() { |
| 2124 | $orig_str = '<a href="#">0<abbr>1</abbr></a>2<b>2</b>345<big>5</big>6<br>77<dfn></em>8<i><samp>9</samp>A<small>B</small>CDE<span></span>F<strong>G</sub>[H<sup>]<var>I</var>'; |
| 2125 | |
| 2126 | $str = $orig_str; |
| 2127 | wptexturize_replace_init( $str, '/<[^>]*>|\[H[^\]]*\]/' ); |
| 2128 | $this->assertEquals( '0122345567789ABCDEFGI', $str ); |
| 2129 | |
| 2130 | wptexturize_replace_final( $str ); |
| 2131 | $this->assertEquals( $orig_str, $str ); |
| 2132 | |
| 2133 | wptexturize_replace_init( $str, '/<[^>]*>|\[H[^\]]*\]/' ); |
| 2134 | $this->assertEquals( '0122345567789ABCDEFGI', $str ); |
| 2135 | |
| 2136 | wptexturize_replace_str( $str, '5', 'EF' ); |
| 2137 | $this->assertEquals( '012234EFEF67789ABCDEFGI', $str ); |
| 2138 | |
| 2139 | wptexturize_replace_regex( $str, '/2/', '2BB2' ); |
| 2140 | $this->assertEquals( '012BB22BB234EFEF67789ABCDEFGI', $str ); |
| 2141 | |
| 2142 | wptexturize_replace_regex( $str, '/(3)4/', '$1FOUR' ); |
| 2143 | $this->assertEquals( '012BB22BB23FOUREFEF67789ABCDEFGI', $str ); |
| 2144 | |
| 2145 | wptexturize_replace_str( $str, '8', 'B' ); |
| 2146 | $this->assertEquals( '012BB22BB23FOUREFEF677B9ABCDEFGI', $str ); |
| 2147 | |
| 2148 | wptexturize_replace_regex( $str, '/7/', '7EFEN' ); |
| 2149 | $this->assertEquals( '012BB22BB23FOUREFEF67EFEN7EFENB9ABCDEFGI', $str ); |
| 2150 | |
| 2151 | wptexturize_replace_str( $str, '6', '666' ); |
| 2152 | $this->assertEquals( '012BB22BB23FOUREFEF6667EFEN7EFENB9ABCDEFGI', $str ); |
| 2153 | |
| 2154 | wptexturize_replace_str( $str, '1', '12' ); |
| 2155 | $this->assertEquals( '0122BB22BB23FOUREFEF6667EFEN7EFENB9ABCDEFGI', $str ); |
| 2156 | |
| 2157 | wptexturize_replace_str( $str, 'BC', 'BCBC' ); |
| 2158 | $this->assertEquals( '0122BB22BB23FOUREFEF6667EFEN7EFENB9ABCBCDEFGI', $str ); |
| 2159 | |
| 2160 | wptexturize_replace_regex( $str, '/3(FO)U/', 'THREE$1EWE' ); |
| 2161 | $this->assertEquals( '0122BB22BB2THREEFOEWEREFEF6667EFEN7EFENB9ABCBCDEFGI', $str ); |
| 2162 | |
| 2163 | wptexturize_replace_regex( $str, '/(E)F/', '$1' ); |
| 2164 | $this->assertEquals( '0122BB22BB2THREEOEWEREE6667EEN7EENB9ABCBCDEGI', $str ); |
| 2165 | |
| 2166 | wptexturize_replace_regex( $str, '/G/', '' ); |
| 2167 | $this->assertEquals( '0122BB22BB2THREEOEWEREE6667EEN7EENB9ABCBCDEI', $str ); |
| 2168 | |
| 2169 | wptexturize_replace_final( $str ); |
| 2170 | $this->assertEquals( '<a href="#">0<abbr>12</abbr></a>2BB2<b>2BB2</b>THREEOEWERE<big>E</big>666<br>7EEN7EEN<dfn></em>B<i><samp>9</samp>A<small>BCBC</small>DE<span></span><strong></sub>[H<sup>]<var>I</var>', $str ); |
| 2171 | } |
| 2172 | } |