Ticket #46230: 46230.unit-test.diff
File 46230.unit-test.diff, 1.5 KB (added by , 6 years ago) |
---|
-
tests/phpunit/tests/l10n/localeSwitcher.php
class Tests_Locale_Switcher extends WP_U 64 64 65 65 $this->assertSame( 'en_GB', $locale ); 66 66 } 67 67 68 68 public function test_switch_to_locale_loads_translation() { 69 69 switch_to_locale( 'es_ES' ); 70 70 71 71 $actual = __( 'Invalid parameter.' ); 72 72 73 73 // Cleanup. 74 74 restore_previous_locale(); 75 75 76 76 $this->assertSame( 'Parámetro no válido. ', $actual ); 77 77 } 78 78 79 /** 80 * @ticket 46230 81 */ 82 public function test_switch_to_locale_loads_translation_multiple_times() { 83 require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php'; 84 85 $english = i18n_plugin_test(); 86 87 switch_to_locale( 'de_DE' ); 88 $actual = i18n_plugin_test(); 89 restore_previous_locale(); 90 91 switch_to_locale( 'de_DE' ); 92 $actual_two = i18n_plugin_test(); 93 restore_previous_locale(); 94 95 $this->assertSame( 'This is a dummy plugin', $english ); 96 $this->assertSame( 'Das ist ein Dummy Plugin', $actual ); 97 $this->assertSame( 'Das ist ein Dummy Plugin', $actual_two ); 98 } 99 79 100 public function test_switch_to_locale_changes_wp_locale_global() { 80 101 global $wp_locale; 81 102 82 103 $expected = array( 83 104 'thousands_sep' => '.', 84 105 'decimal_point' => ',', 85 106 ); 86 107 87 108 switch_to_locale( 'de_DE' ); 88 109 89 110 $wp_locale_de_DE = clone $wp_locale; 90 111 91 112 // Cleanup. 92 113 restore_previous_locale(); 93 114