diff --git a/tests/phpunit/tests/formatting/wptexturizePrimes.php b/tests/phpunit/tests/formatting/wptexturizePrimes.php new file mode 100644 index 0000000000000..ec4954d2c77a4 --- /dev/null +++ b/tests/phpunit/tests/formatting/wptexturizePrimes.php @@ -0,0 +1,86 @@ +assertSame( $expected, wptexturize_primes( $input, "'", $prime, $open_quote, $close_quote ) ); + } + + /** + * Tests double prime replacement for double quotes after numbers. + * + * @ticket 66609 + */ + public function test_wptexturize_primes_double_quote() { + $prime = '″'; + $open_quote = '“'; + $close_quote = '”'; + + $input = 'A 12" record.'; + $expected = "A 12{$prime} record."; + + $this->assertSame( $expected, wptexturize_primes( $input, '"', $prime, $open_quote, $close_quote ) ); + } + + /** + * Tests that text without the needle character is returned unchanged. + * + * @ticket 66609 + */ + public function test_wptexturize_primes_without_matching_needle() { + $text = 'Text without any quotes at all.'; + + $this->assertSame( $text, wptexturize_primes( $text, "'", '′', '‘', '’' ) ); + } + + /** + * Tests closing quote disambiguation when numbers with primes are inside quotations. + * + * @ticket 66609 + */ + public function test_wptexturize_primes_inside_quotations() { + $prime = '′'; + $open_quote = '‘'; + $close_quote = '’'; + + $input = "{$open_quote}I am 6' tall.'"; + $expected = "{$open_quote}I am 6{$prime} tall.{$close_quote}"; + + $this->assertSame( $expected, wptexturize_primes( $input, "'", $prime, $open_quote, $close_quote ) ); + } + + /** + * Tests that quotes not preceded by numbers become closing quotes. + * + * @ticket 66609 + */ + public function test_wptexturize_primes_normal_quotes_become_closing_quotes() { + $prime = '″'; + $open_quote = '“'; + $close_quote = '”'; + + $input = 'A "quoted word".'; + $expected = "A {$close_quote}quoted word{$close_quote}."; + + $this->assertSame( $expected, wptexturize_primes( $input, '"', $prime, $open_quote, $close_quote ) ); + } +}