Tests: Use DIR_TESTDATA in test_wp_set_script_translation().

`__DIR__` is not available in PHP 5.2.x.

See #45103.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43828 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2018-10-26 03:54:02 +00:00
parent ebcfbfe286
commit 845f569b46

View File

@ -773,12 +773,12 @@ class Tests_Dependencies_Scripts extends WP_UnitTestCase {
public function test_wp_set_script_translation() {
wp_register_script( 'wp-i18n', '/wp-includes/js/dist/wp-i18n.js', array(), null );
wp_enqueue_script( 'test-example', '/wp-includes/js/script.js', array(), null );
wp_set_script_translations( 'test-example', 'default', __DIR__ . '/../../data/languages/' );
wp_set_script_translations( 'test-example', 'default', DIR_TESTDATA . '/languages/' );
$expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
$expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
"wp.i18n.setLocaleData( translations.locale_data, \"default\" );" .
"})(" . file_get_contents( __DIR__ . '/../../data/languages/default-en_US-813e104eb47e13dd4cc5af844c618754.json') . ");\n</script>\n";
"})(" . file_get_contents( DIR_TESTDATA . '/languages/default-en_US-813e104eb47e13dd4cc5af844c618754.json') . ");\n</script>\n";
$expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );