mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
I18N: Improvements to the tests for plural forms.
* Move the `create_function()` code into a file that's only loaded, and into a test that's only run, on PHP <= 7.2 to avoid deprecated warnings in 7.2+. * Convert the test skipping into a failure if the GlotPress locale file cannot be downloaded. * Ensure `test_exceptions` fails if an exception is not thrown. * Docs improvements See #41562, #40109 git-svn-id: https://develop.svn.wordpress.org/trunk@41730 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
16
tests/phpunit/includes/plural-form-function.php
Normal file
16
tests/phpunit/includes/plural-form-function.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Legacy plural form function.
|
||||
*
|
||||
* @param int $nplurals
|
||||
* @param string $expression
|
||||
*/
|
||||
function tests_make_plural_form_function( $nplurals, $expression ) {
|
||||
$expression = str_replace( 'n', '$n', $expression );
|
||||
$func_body = "
|
||||
\$index = (int)($expression);
|
||||
return (\$index < $nplurals)? \$index : $nplurals - 1;";
|
||||
|
||||
return create_function( '$n', $func_body );
|
||||
}
|
||||
Reference in New Issue
Block a user