Changeset 49236 for trunk/tests/phpunit/tests/l10n/localeSwitcher.php
- Timestamp:
- 10/20/2020 04:03:58 PM (5 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/l10n/localeSwitcher.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/l10n/localeSwitcher.php
r48939 r49236 23 23 $this->previous_locale = ''; 24 24 25 unset( $GLOBALS['l10n'] ); 26 unset( $GLOBALS['l10n_unloaded'] ); 27 _get_path_to_translation( null, true ); 25 unset( $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] ); 26 27 /** @var WP_Textdomain_Registry $wp_textdomain_registry */ 28 global $wp_textdomain_registry; 29 30 $wp_textdomain_registry->reset(); 28 31 } 29 32 30 33 public function tearDown() { 31 unset( $GLOBALS['l10n'] ); 32 unset( $GLOBALS['l10n_unloaded'] ); 33 _get_path_to_translation( null, true ); 34 unset( $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] ); 35 36 /** @var WP_Textdomain_Registry $wp_textdomain_registry */ 37 global $wp_textdomain_registry; 38 39 $wp_textdomain_registry->reset(); 34 40 35 41 parent::tearDown(); … … 389 395 } 390 396 397 /** 398 * @ticket 39210 399 */ 400 public function test_switch_reloads_plugin_translations_outside_wp_lang_dir() { 401 global $wp_locale_switcher, $wp_textdomain_registry; 402 403 $locale_switcher = clone $wp_locale_switcher; 404 405 $wp_locale_switcher = new WP_Locale_Switcher(); 406 $wp_locale_switcher->init(); 407 408 require_once DIR_TESTDATA . '/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php'; 409 410 $this->assertSame( WP_PLUGIN_DIR . '/custom-internationalized-plugin/languages/', $wp_textdomain_registry->get( 'custom-internationalized-plugin' ) ); 411 412 $expected = custom_i18n_plugin_test(); 413 $this->assertSame( 'This is a dummy plugin', $expected ); 414 415 switch_to_locale( 'es_ES' ); 416 switch_to_locale( 'de_DE' ); 417 418 $expected = custom_i18n_plugin_test(); 419 $this->assertSame( 'Das ist ein Dummy Plugin', $expected ); 420 421 restore_previous_locale(); 422 423 $expected = custom_i18n_plugin_test(); 424 $this->assertSame( 'Este es un plugin dummy', $expected ); 425 426 restore_current_locale(); 427 428 $wp_locale_switcher = $locale_switcher; 429 } 430 431 /** 432 * @ticket 39210 433 */ 434 public function test_switch_reloads_theme_translations_outside_wp_lang_dir() { 435 global $wp_locale_switcher, $wp_textdomain_registry; 436 437 $locale_switcher = clone $wp_locale_switcher; 438 439 $wp_locale_switcher = new WP_Locale_Switcher(); 440 $wp_locale_switcher->init(); 441 442 switch_theme( 'custom-internationalized-theme' ); 443 444 require_once get_stylesheet_directory() . '/functions.php'; 445 446 $this->assertSame( get_template_directory() . '/languages/', $wp_textdomain_registry->get( 'custom-internationalized-theme' ) ); 447 448 $expected = custom_i18n_theme_test(); 449 450 $this->assertSame( 'This is a dummy theme', $expected ); 451 452 switch_to_locale( 'es_ES' ); 453 switch_to_locale( 'de_DE' ); 454 455 $expected = custom_i18n_theme_test(); 456 $this->assertSame( 'Das ist ein Dummy Theme', $expected ); 457 458 restore_previous_locale(); 459 460 $expected = custom_i18n_theme_test(); 461 $this->assertSame( 'Este es un tema dummy', $expected ); 462 463 restore_current_locale(); 464 465 $wp_locale_switcher = $locale_switcher; 466 } 467 391 468 public function filter_locale() { 392 469 return 'es_ES';
Note: See TracChangeset
for help on using the changeset viewer.