wptexturize() adjustments:

* Only place an apostrophe before a number when it has exactly two digits.
* Never match '99' with the single prime pattern.
* Always assume '99' is an abbreviated year at the end of a quotation.
* Add unit tests.
* Resolves the unit test broken in [28721] for #8775.

See #26850.


git-svn-id: https://develop.svn.wordpress.org/trunk@28761 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2014-06-17 17:40:07 +00:00
parent abddfc4b99
commit 03a6e5f1fb
2 changed files with 94 additions and 6 deletions

View File

@@ -1279,4 +1279,87 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
),
);
}
}
/**
* Year abbreviations consist of exactly two digits.
*
* @ticket 26850
* @dataProvider data_quotes_and_dashes
*/
function test_year_abbr( $input, $output ) {
return $this->assertEquals( $output, wptexturize( $input ) );
}
function data_year_abbr() {
return array(
array(
"word '99 word",
"word ’99 word",
),
array(
"word '99. word",
"word ’99. word",
),
array(
"word '99, word",
"word ’99, word",
),
array(
"word '99; word",
"word ’99; word",
),
array(
"word '99' word", // For this pattern, prime doesn't make sense. Should get apos and a closing quote.
"word ’99’ word",
),
array(
"word '99'. word",
"word ’99’. word",
),
array(
"word '99', word",
"word ’99’, word",
),
array(
"word '99.' word",
"word ’99.’ word",
),
array(
"word '99",
"word ’99",
),
array(
"'99 word",
"’99 word",
),
array(
"word '999 word", // Does not match the apos pattern, should be opening quote.
"word ‘999 word",
),
array(
"word '9 word",
"word ‘9 word",
),
array(
"word '99.9 word",
"word ‘99.9 word",
),
array(
"word '999",
"word ‘999",
),
array(
"word '9",
"word ‘9",
),
array(
"in '4 years, 3 months,' Obama cut the deficit",
"in ‘4 years, 3 months,’ Obama cut the deficit",
),
array(
"testing's '4' through 'quotes'",
"testing’s ‘4’ through ‘quotes’",
),
);
}
}