@@ -32,6 +32,29 @@ public function testDumpMessagesAndClean()
3232 $ this ->assertRegExp ('/1 message was successfully extracted/ ' , $ tester ->getDisplay ());
3333 }
3434
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+
3558 public function testDumpMessagesAndCleanInRootDirectory ()
3659 {
3760 $ this ->fs ->remove ($ this ->translationDir );
@@ -118,7 +141,10 @@ protected function tearDown(): void
118141 $ this ->fs ->remove ($ this ->translationDir );
119142 }
120143
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 = [])
122148 {
123149 $ translator = $ this ->getMockBuilder ('Symfony\Component\Translation\Translator ' )
124150 ->disableOriginalConstructor ()
0 commit comments