- Timestamp:
- 10/24/2022 10:01:01 AM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php
r53874 r54669 9 9 protected $theme_root; 10 10 protected static $user_id; 11 private $locale_count;12 11 13 12 public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { … … 25 24 $this->theme_root = DIR_TESTDATA . '/themedir1'; 26 25 $this->orig_theme_dir = $GLOBALS['wp_theme_directories']; 27 $this->locale_count = 0;28 26 29 27 // /themes is necessary as theme.php functions assume /themes is the root if there is only one root. … … 38 36 global $wp_textdomain_registry; 39 37 40 $wp_textdomain_registry ->reset();38 $wp_textdomain_registry = new WP_Textdomain_Registry(); 41 39 } 42 40 … … 49 47 global $wp_textdomain_registry; 50 48 51 $wp_textdomain_registry ->reset();49 $wp_textdomain_registry = new WP_Textdomain_Registry(); 52 50 53 51 parent::tear_down(); … … 263 261 $textdomain = 'foo-bar-baz'; 264 262 265 add_filter( 'locale', array( $this, '_filter_locale_count' ) ); 263 $filter = new MockAction(); 264 add_filter( 'locale', array( $filter, 'filter' ) ); 266 265 267 266 __( 'Foo', $textdomain ); … … 271 270 __( 'Foo Bar Baz', $textdomain ); 272 271 273 remove_filter( 'locale', array( $this, '_filter_locale_count' ) );274 275 272 $this->assertFalse( is_textdomain_loaded( $textdomain ) ); 276 $this->assertSame( 1, $this->locale_count ); 277 } 278 279 public function _filter_locale_count( $locale ) { 280 ++$this->locale_count; 281 282 return $locale; 273 $this->assertSame( 1, $filter->get_call_count() ); 274 } 275 276 /** 277 * @ticket 37997 278 * @ticket 39210 279 * 280 * @covers ::_load_textdomain_just_in_time 281 */ 282 public function test_get_locale_is_called_only_once_per_textdomain_with_custom_lang_dir() { 283 load_plugin_textdomain( 'custom-internationalized-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 284 285 $textdomain = 'custom-internationalized-plugin'; 286 287 $filter = new MockAction(); 288 add_filter( 'locale', array( $filter, 'filter' ) ); 289 290 __( 'Foo', $textdomain ); 291 __( 'Bar', $textdomain ); 292 __( 'Baz', $textdomain ); 293 __( 'Foo Bar', $textdomain ); 294 __( 'Foo Bar Baz', $textdomain ); 295 296 $this->assertFalse( is_textdomain_loaded( $textdomain ) ); 297 $this->assertSame( 1, $filter->get_call_count() ); 283 298 } 284 299 }
Note: See TracChangeset
for help on using the changeset viewer.