@@ -32,6 +32,29 @@ public function testDumpMessagesAndClean()
32
32
$ this ->assertRegExp ('/1 message was successfully extracted/ ' , $ tester ->getDisplay ());
33
33
}
34
34
35
+ public function testDumpSortedMessagesAndClean ()
36
+ {
37
+ $ tester = $ this ->createCommandTester (['messages ' => ['foo ' => 'foo ' , 'test ' => 'test ' , 'bar ' => 'bar ' ]]);
38
+ $ tester ->execute (['command ' => 'translation:update ' , 'locale ' => 'en ' , 'bundle ' => 'foo ' , '--dump-messages ' => true , '--clean ' => true , '--sort ' => 'asc ' ]);
39
+ $ this ->assertRegExp ("/\*bar\*foo\*test/ " , preg_replace ('/\s+/ ' , '' , $ tester ->getDisplay ()));
40
+ $ this ->assertRegExp ('/3 messages were successfully extracted/ ' , $ tester ->getDisplay ());
41
+ }
42
+
43
+ public function testDumpReverseSortedMessagesAndClean ()
44
+ {
45
+ $ tester = $ this ->createCommandTester (['messages ' => ['foo ' => 'foo ' , 'test ' => 'test ' , 'bar ' => 'bar ' ]]);
46
+ $ tester ->execute (['command ' => 'translation:update ' , 'locale ' => 'en ' , 'bundle ' => 'foo ' , '--dump-messages ' => true , '--clean ' => true , '--sort ' => 'desc ' ]);
47
+ $ this ->assertRegExp ("/\*test\*foo\*bar/ " , preg_replace ('/\s+/ ' , '' , $ tester ->getDisplay ()));
48
+ $ this ->assertRegExp ('/3 messages were successfully extracted/ ' , $ tester ->getDisplay ());
49
+ }
50
+
51
+ public function testDumpWrongSortAndClean ()
52
+ {
53
+ $ tester = $ this ->createCommandTester (['messages ' => ['foo ' => 'foo ' , 'test ' => 'test ' , 'bar ' => 'bar ' ]]);
54
+ $ tester ->execute (['command ' => 'translation:update ' , 'locale ' => 'en ' , 'bundle ' => 'foo ' , '--dump-messages ' => true , '--clean ' => true , '--sort ' => 'test ' ]);
55
+ $ this ->assertRegExp ('/\[ERROR\] Wrong sort order/ ' , $ tester ->getDisplay ());
56
+ }
57
+
35
58
public function testDumpMessagesAndCleanInRootDirectory ()
36
59
{
37
60
$ this ->fs ->remove ($ this ->translationDir );
@@ -118,7 +141,10 @@ protected function tearDown(): void
118
141
$ this ->fs ->remove ($ this ->translationDir );
119
142
}
120
143
121
- private function createCommandTester ($ extractedMessages = [], $ loadedMessages = [], HttpKernel \KernelInterface $ kernel = null , array $ transPaths = [], array $ viewsPaths = []): CommandTester
144
+ /**
145
+ * @return CommandTester
146
+ */
147
+ private function createCommandTester ($ extractedMessages = [], $ loadedMessages = [], HttpKernel \KernelInterface $ kernel = null , array $ transPaths = [], array $ viewsPaths = [])
122
148
{
123
149
$ translator = $ this ->getMockBuilder ('Symfony\Component\Translation\Translator ' )
124
150
->disableOriginalConstructor ()
0 commit comments