mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
i18n: Prevent is_textdomain_loaded() from returning true even if there are no translations for the domain.
In `get_translations_for_domain()` don't fill the global `$l10n` with `NOOP_Translations` instances, return a `NOOP_Translations` instance instead. Props nacin, jrf. Fixes #21319. git-svn-id: https://develop.svn.wordpress.org/trunk@36538 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -26,4 +26,24 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'first-before-bar|second-before-bar', before_last_bar( 'first-before-bar|second-before-bar|after-last-bar' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 21319
|
||||
*/
|
||||
function test_is_textdomain_loaded_for_no_translations() {
|
||||
$this->assertFalse( load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ) );
|
||||
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
|
||||
$this->assertInstanceOf( 'NOOP_Translations', get_translations_for_domain( 'wp-tests-domain' ) );
|
||||
// Ensure that we don't confuse NOOP_Translations to be a loaded text domain.
|
||||
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
|
||||
$this->assertFalse( unload_textdomain( 'wp-tests-domain' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 21319
|
||||
*/
|
||||
function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() {
|
||||
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
|
||||
__( 'just some string', 'wp-tests-domain' );
|
||||
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user