Skip to content

Commit d69dbf0

Browse files
committed
Utils/I18nTextDomainFixer: add tests to safeguard that namespaced names are handled correctly
There were already a few tests with namespaced names, so this commit adds only what was missing in the existing tests.
1 parent 3c9ebab commit d69dbf0

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.4.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,5 +281,13 @@ __ (
281281
$args
282282
);
283283

284+
/*
285+
* Safeguard correct handling of namespaced function calls (partially qualified is already tested above).
286+
*/
287+
\MyNamespace\load_textdomain( 'text-domain', '/path/to/file.mo' );
288+
namespace\load_textdomain( 'text-domain', '/path/to/file.mo' );
289+
\load_textdomain( 'text-domain', '/path/to/file.mo' );
290+
\load_textdomain();
291+
284292
// phpcs:set WordPress.Utils.I18nTextDomainFixer old_text_domain[]
285293
// phpcs:set WordPress.Utils.I18nTextDomainFixer new_text_domain false

WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.4.inc.fixed

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,13 @@ __ (
287287
'something-else'
288288
);
289289

290+
/*
291+
* Safeguard correct handling of namespaced function calls (partially qualified is already tested above).
292+
*/
293+
\MyNamespace\load_textdomain( 'text-domain', '/path/to/file.mo' );
294+
namespace\load_textdomain( 'text-domain', '/path/to/file.mo' );
295+
\load_textdomain( 'something-else', '/path/to/file.mo' );
296+
\load_textdomain( 'something-else' );
297+
290298
// phpcs:set WordPress.Utils.I18nTextDomainFixer old_text_domain[]
291299
// phpcs:set WordPress.Utils.I18nTextDomainFixer new_text_domain false

WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ public function getErrorList( $testFile = '' ) {
154154
245 => 1,
155155
277 => 1,
156156
278 => 1,
157+
289 => 1,
158+
290 => 1,
157159
);
158160

159161
default:

0 commit comments

Comments
 (0)