|
|
|
@@ -30,9 +30,9 @@ class WP_Translation_Controller_Tests extends WP_UnitTestCase {
|
|
|
|
|
|
|
|
|
|
$compat_instance = $l10n['wp-tests-domain'] ?? null;
|
|
|
|
|
|
|
|
|
|
$is_loaded = WP_Translation_Controller::instance()->is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
$headers = WP_Translation_Controller::instance()->get_headers( 'wp-tests-domain' );
|
|
|
|
|
$entries = WP_Translation_Controller::instance()->get_entries( 'wp-tests-domain' );
|
|
|
|
|
$is_loaded = WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
$headers = WP_Translation_Controller::get_instance()->get_headers( 'wp-tests-domain' );
|
|
|
|
|
$entries = WP_Translation_Controller::get_instance()->get_entries( 'wp-tests-domain' );
|
|
|
|
|
|
|
|
|
|
$unload_successful = unload_textdomain( 'wp-tests-domain' );
|
|
|
|
|
|
|
|
|
@@ -76,7 +76,7 @@ class WP_Translation_Controller_Tests extends WP_UnitTestCase {
|
|
|
|
|
|
|
|
|
|
$is_loaded_wp = is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
|
|
|
|
|
$is_loaded = WP_Translation_Controller::instance()->is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
$is_loaded = WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
|
|
|
|
|
remove_filter( 'override_load_textdomain', '__return_true' );
|
|
|
|
|
|
|
|
|
@@ -102,7 +102,7 @@ class WP_Translation_Controller_Tests extends WP_UnitTestCase {
|
|
|
|
|
public function test_load_textdomain_prefers_php_files_by_default() {
|
|
|
|
|
$load_successful = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' );
|
|
|
|
|
|
|
|
|
|
$instance = WP_Translation_Controller::instance();
|
|
|
|
|
$instance = WP_Translation_Controller::get_instance();
|
|
|
|
|
|
|
|
|
|
$is_loaded = $instance->is_textdomain_loaded( 'wp-tests-domain', 'en_US' );
|
|
|
|
|
|
|
|
|
@@ -259,9 +259,9 @@ class WP_Translation_Controller_Tests extends WP_UnitTestCase {
|
|
|
|
|
|
|
|
|
|
$compat_instance = $l10n['wp-tests-domain'] ?? null;
|
|
|
|
|
|
|
|
|
|
$is_loaded = WP_Translation_Controller::instance()->is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
$headers = WP_Translation_Controller::instance()->get_headers( 'wp-tests-domain' );
|
|
|
|
|
$entries = WP_Translation_Controller::instance()->get_entries( 'wp-tests-domain' );
|
|
|
|
|
$is_loaded = WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
$headers = WP_Translation_Controller::get_instance()->get_headers( 'wp-tests-domain' );
|
|
|
|
|
$entries = WP_Translation_Controller::get_instance()->get_entries( 'wp-tests-domain' );
|
|
|
|
|
|
|
|
|
|
$this->assertNull( $compat_instance, 'Compat instance was not removed' );
|
|
|
|
|
$this->assertTrue( $unload_successful, 'Text domain not successfully unloaded' );
|
|
|
|
@@ -281,13 +281,13 @@ class WP_Translation_Controller_Tests extends WP_UnitTestCase {
|
|
|
|
|
|
|
|
|
|
$unload_successful = unload_textdomain( 'wp-tests-domain' );
|
|
|
|
|
|
|
|
|
|
$is_loaded = WP_Translation_Controller::instance()->is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
$is_loaded = WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
|
|
|
|
|
remove_filter( 'override_unload_textdomain', '__return_true' );
|
|
|
|
|
|
|
|
|
|
$unload_successful_after = unload_textdomain( 'wp-tests-domain' );
|
|
|
|
|
|
|
|
|
|
$is_loaded_after = WP_Translation_Controller::instance()->is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
$is_loaded_after = WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'wp-tests-domain' );
|
|
|
|
|
|
|
|
|
|
$this->assertTrue( $unload_successful );
|
|
|
|
|
$this->assertTrue( $is_loaded );
|
|
|
|
@@ -317,14 +317,14 @@ class WP_Translation_Controller_Tests extends WP_UnitTestCase {
|
|
|
|
|
|
|
|
|
|
$actual = __( 'Invalid parameter.' );
|
|
|
|
|
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::instance()->is_textdomain_loaded() );
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::instance()->is_textdomain_loaded( 'default', 'es_ES' ) );
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::get_instance()->is_textdomain_loaded() );
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'default', 'es_ES' ) );
|
|
|
|
|
|
|
|
|
|
restore_previous_locale();
|
|
|
|
|
|
|
|
|
|
$actual_2 = __( 'Invalid parameter.' );
|
|
|
|
|
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::instance()->is_textdomain_loaded( 'default', 'es_ES' ) );
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'default', 'es_ES' ) );
|
|
|
|
|
|
|
|
|
|
$this->assertSame( 'Parámetro no válido. ', $actual );
|
|
|
|
|
$this->assertSame( 'Invalid parameter.', $actual_2 );
|
|
|
|
@@ -336,7 +336,7 @@ class WP_Translation_Controller_Tests extends WP_UnitTestCase {
|
|
|
|
|
* @covers ::change_locale
|
|
|
|
|
*/
|
|
|
|
|
public function test_switch_to_locale_translations_stay_loaded_custom_textdomain() {
|
|
|
|
|
$this->assertSame( 'en_US', WP_Translation_Controller::instance()->get_locale() );
|
|
|
|
|
$this->assertSame( 'en_US', WP_Translation_Controller::get_instance()->get_locale() );
|
|
|
|
|
|
|
|
|
|
require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
|
|
|
|
|
|
|
|
|
@@ -346,16 +346,16 @@ class WP_Translation_Controller_Tests extends WP_UnitTestCase {
|
|
|
|
|
|
|
|
|
|
$actual = i18n_plugin_test();
|
|
|
|
|
|
|
|
|
|
$this->assertSame( 'es_ES', WP_Translation_Controller::instance()->get_locale() );
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::instance()->is_textdomain_loaded( 'internationalized-plugin', 'es_ES' ) );
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::instance()->is_textdomain_loaded( 'default', 'es_ES' ) );
|
|
|
|
|
$this->assertFalse( WP_Translation_Controller::instance()->is_textdomain_loaded( 'foo-bar', 'es_ES' ) );
|
|
|
|
|
$this->assertSame( 'es_ES', WP_Translation_Controller::get_instance()->get_locale() );
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'internationalized-plugin', 'es_ES' ) );
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'default', 'es_ES' ) );
|
|
|
|
|
$this->assertFalse( WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'foo-bar', 'es_ES' ) );
|
|
|
|
|
|
|
|
|
|
restore_previous_locale();
|
|
|
|
|
|
|
|
|
|
$after = i18n_plugin_test();
|
|
|
|
|
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::instance()->is_textdomain_loaded( 'internationalized-plugin', 'es_ES' ) );
|
|
|
|
|
$this->assertTrue( WP_Translation_Controller::get_instance()->is_textdomain_loaded( 'internationalized-plugin', 'es_ES' ) );
|
|
|
|
|
|
|
|
|
|
$this->assertSame( 'This is a dummy plugin', $before );
|
|
|
|
|
$this->assertSame( 'Este es un plugin dummy', $actual );
|
|
|
|
|