9
9
* file that was distributed with this source code.
10
10
*/
11
11
12
- namespace Command ;
12
+ namespace Symfony \ Component \ Translation \ Tests \ Command ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
15
use Symfony \Component \Console \Application ;
@@ -34,8 +34,8 @@ class XliffUpdateSourcesCommandTest extends TestCase
34
34
protected function setUp (): void
35
35
{
36
36
$ this ->fs = new Filesystem ();
37
- $ this ->translationAppDir = sprintf ('%s/translation-xliff-update-source-test ' , sys_get_temp_dir ());
38
- $ this ->fs ->mkdir (sprintf ('%s/translations ' , $ this ->translationAppDir ));
37
+ $ this ->translationAppDir = \ sprintf ('%s/translation-xliff-update-source-test ' , sys_get_temp_dir ());
38
+ $ this ->fs ->mkdir (\ sprintf ('%s/translations ' , $ this ->translationAppDir ));
39
39
}
40
40
41
41
protected function tearDown (): void
@@ -108,7 +108,7 @@ public function testFilesAreUpdatedOnlyForSpecifiedLocales()
108
108
109
109
public function testFilesAreUpdatedInOtherTranslationPaths ()
110
110
{
111
- $ otherPath = sprintf ('%s/other ' , $ this ->translationAppDir );
111
+ $ otherPath = \ sprintf ('%s/other ' , $ this ->translationAppDir );
112
112
$ this ->fs ->mkdir ($ otherPath );
113
113
114
114
$ originalContent = $ this ->createXliff1 ('en ' , 'foo ' , 'foo ' , 'bar-en ' );
@@ -120,22 +120,22 @@ public function testFilesAreUpdatedInOtherTranslationPaths()
120
120
121
121
$ tester ->assertCommandIsSuccessful ();
122
122
123
- $ this ->assertStringContainsString (sprintf ('Updating XLIFF files in %s... ' , $ otherPath ), $ tester ->getDisplay ());
123
+ $ this ->assertStringContainsString (\ sprintf ('Updating XLIFF files in %s... ' , $ otherPath ), $ tester ->getDisplay ());
124
124
125
125
$ expectedContent = $ this ->createXliff1 ('en ' , 'foo ' , 'bar-en ' , 'bar-en ' );
126
126
127
127
// other/messages.en.xlf should be updated
128
128
$ this ->assertStringEqualsFile ($ enFileInOtherDir , $ expectedContent );
129
129
130
130
// translations/messages.en.xlf should be updated
131
- $ this ->assertStringContainsString (sprintf ('Updating XLIFF files in %s/translations... ' , $ this ->translationAppDir ), $ tester ->getDisplay ());
131
+ $ this ->assertStringContainsString (\ sprintf ('Updating XLIFF files in %s/translations... ' , $ this ->translationAppDir ), $ tester ->getDisplay ());
132
132
$ this ->assertStringEqualsFile ($ enFileInDefaultDir , $ expectedContent );
133
133
}
134
134
135
135
public function testFilesAreUpdatedOnlyForPathsArgument ()
136
136
{
137
- $ fooDir = sprintf ('%s/foo ' , $ this ->translationAppDir );
138
- $ barDir = sprintf ('%s/bar ' , $ this ->translationAppDir );
137
+ $ fooDir = \ sprintf ('%s/foo ' , $ this ->translationAppDir );
138
+ $ barDir = \ sprintf ('%s/bar ' , $ this ->translationAppDir );
139
139
140
140
$ this ->fs ->mkdir ([$ fooDir , $ barDir ]);
141
141
@@ -150,11 +150,11 @@ public function testFilesAreUpdatedOnlyForPathsArgument()
150
150
151
151
// foo/messages.en.xlf should be updated
152
152
$ updatedContent = $ this ->createXliff1 ('en ' , 'foo ' , 'bar-en ' , 'bar-en ' );
153
- $ this ->assertStringContainsString (sprintf ('Updating XLIFF files in %s... ' , $ fooDir ), $ tester ->getDisplay ());
153
+ $ this ->assertStringContainsString (\ sprintf ('Updating XLIFF files in %s... ' , $ fooDir ), $ tester ->getDisplay ());
154
154
$ this ->assertStringEqualsFile ($ fileInFooDir , $ updatedContent );
155
155
156
156
// translations/messages.en.xlf shouldn't be updated
157
- $ this ->assertStringNotContainsString (sprintf ('Updating XLIFF files in %s/translations... ' , $ this ->translationAppDir ), $ tester ->getDisplay ());
157
+ $ this ->assertStringNotContainsString (\ sprintf ('Updating XLIFF files in %s/translations... ' , $ this ->translationAppDir ), $ tester ->getDisplay ());
158
158
$ this ->assertStringEqualsFile ($ fileInDefaultDir , $ originalContent );
159
159
}
160
160
@@ -241,7 +241,7 @@ public function testComplete(array $input, array $expectedSuggestions)
241
241
242
242
foreach ($ domainsByLocale as $ locale => $ domains ) {
243
243
foreach ($ domains as $ domain ) {
244
- $ this ->createFile ($ this ->createXliff1 ($ locale , 'foo ' , 'foo ' , 'bar ' ), sprintf ('%s.%s.xlf ' , $ domain , $ locale ));
244
+ $ this ->createFile ($ this ->createXliff1 ($ locale , 'foo ' , 'foo ' , 'bar ' ), \ sprintf ('%s.%s.xlf ' , $ domain , $ locale ));
245
245
}
246
246
}
247
247
@@ -274,7 +274,7 @@ private function createCommand(array $transPaths = [], array $enabledLocales = [
274
274
$ reader ->addLoader ('xlf ' , new XliffFileLoader ());
275
275
$ writer = new TranslationWriter ();
276
276
$ writer ->addDumper ('xlf ' , new XliffFileDumper ());
277
- $ transPaths [] = sprintf ('%s/translations ' , $ this ->translationAppDir );
277
+ $ transPaths [] = \ sprintf ('%s/translations ' , $ this ->translationAppDir );
278
278
279
279
$ command = new XliffUpdateSourcesCommand ($ writer , $ reader , 'en ' , $ transPaths , $ enabledLocales );
280
280
$ application ->add ($ command );
@@ -323,7 +323,7 @@ private function createXliff2(string $locale, string $name, string $source, stri
323
323
324
324
private function createFile (string $ content , string $ filename , string $ directory = 'translations ' ): string
325
325
{
326
- $ filename = sprintf ('%s/%s/%s ' , $ this ->translationAppDir , $ directory , $ filename );
326
+ $ filename = \ sprintf ('%s/%s/%s ' , $ this ->translationAppDir , $ directory , $ filename );
327
327
file_put_contents ($ filename , $ content );
328
328
329
329
return $ filename ;
0 commit comments