@@ -127,7 +127,7 @@ public function testAllFilesShouldBeConverted()
127127
128128 $ contents = file_get_contents ($ this ->outputFilePath );
129129 $ this ->assertContains ('gm8ft2hrrlq1u6m54we9udi ' , $ contents );
130-
130+
131131 $ this ->assertNotContains ('vendor.nonameinc.en.messages ' , $ contents );
132132 $ this ->assertNotContains ('vendor.nonameinc.es.messages ' , $ contents );
133133 $ this ->assertNotContains ('vendor.nonameinc.ht.messages ' , $ contents );
@@ -323,6 +323,48 @@ public function testChangeDefaultLangSourceFolderForOneThatDosentExist()
323323 );
324324 }
325325
326+ /**
327+ * Test that messages are sorted alphabetically by default.
328+ */
329+ public function testDoesSortMessages ()
330+ {
331+ $ generator = new LangJsGenerator (new File (), $ this ->langPath , ['pagination ' ]);
332+
333+ $ command = new LangJsCommand ($ generator );
334+ $ command ->setLaravel ($ this ->app );
335+
336+ $ code = $ this ->runCommand ($ command , ['target ' => $ this ->outputFilePath ]);
337+ $ this ->assertRunsWithSuccess ($ code );
338+ $ this ->assertFileExists ($ this ->outputFilePath );
339+
340+ $ contents = file_get_contents ($ this ->outputFilePath );
341+ $ this ->assertContains ('en.pagination ' , $ contents );
342+ $ this ->assertContains ('{"next":"Next »","previous":"« Previous"} ' , $ contents );
343+
344+ $ this ->cleanupOutputDirectory ();
345+ }
346+
347+ /**
348+ * Tests that the --no-sort option does not sort messages.
349+ */
350+ public function testDoesNotSortMessages ()
351+ {
352+ $ generator = new LangJsGenerator (new File (), $ this ->langPath , ['pagination ' ]);
353+
354+ $ command = new LangJsCommand ($ generator );
355+ $ command ->setLaravel ($ this ->app );
356+
357+ $ code = $ this ->runCommand ($ command , ['target ' => $ this ->outputFilePath , '--no-sort ' => true ]);
358+ $ this ->assertRunsWithSuccess ($ code );
359+ $ this ->assertFileExists ($ this ->outputFilePath );
360+
361+ $ contents = file_get_contents ($ this ->outputFilePath );
362+ $ this ->assertContains ('en.pagination ' , $ contents );
363+ $ this ->assertContains ('{"previous":"« Previous","next":"Next »"} ' , $ contents );
364+
365+ $ this ->cleanupOutputDirectory ();
366+ }
367+
326368 /**
327369 * Run the command.
328370 *
0 commit comments