You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tests: Add end-to-end coverage for script module translation printing.
Add two integration tests verifying the full translation flow:
- test_print_script_module_translations_outputs_set_locale_data covers
the happy path, asserting that the inline script contains the
expected module ID, the wp.i18n.setLocaleData() call, and the
translated string.
- test_print_script_module_translations_includes_dependencies covers
translations for dependency modules (not just directly enqueued ones).
Both tests use the pre_load_script_translations filter to provide
mock translation data inline, so no fixture JSON files are needed.
See #65015.
$this->assertStringContainsString( 'test-module-js-module-translations', $output, 'Translation inline script should be printed with the expected ID.' );
2727
+
$this->assertStringContainsString( 'wp.i18n.setLocaleData', $output, 'Output should call wp.i18n.setLocaleData().' );
2728
+
$this->assertStringContainsString( 'Hola', $output, 'Output should contain the translated string.' );
2729
+
}
2730
+
2731
+
/**
2732
+
* Tests that print_script_module_translations() also outputs translations
2733
+
* for dependencies of enqueued modules (not just directly enqueued ones).
0 commit comments