11<?php
22
3- use Themsaid \Langman \Manager ;
4-
53class RenameCommandTest extends TestCase
64{
75 public function testRenameAKeyValue ()
86 {
97 $ this ->createTempFiles ([
108 'en ' => ['user ' => "<?php \n return['mobile' => 'Mobile']; " ],
119 ]);
12- $ expectedValues = ['contact ' => 'Mobile ' ];
1310
14- $ this ->artisan ('langman:rename ' , ['key ' => 'user.mobile ' , 'as ' => 'contact ' ]);
11+ $ this ->artisan ('langman:rename ' , ['oldKey ' => 'user.mobile ' , 'newKey ' => 'contact ' ]);
1512
1613 $ newValue = (array ) include $ this ->app ['config ' ]['langman.path ' ].'/en/user.php ' ;
17- $ this ->assertEquals ($ expectedValues , $ newValue );
14+
15+ $ this ->assertEquals (['contact ' => 'Mobile ' ], $ newValue );
1816 }
1917
2018 public function testRenameAKeyValueForAllLanguages ()
@@ -26,10 +24,11 @@ public function testRenameAKeyValueForAllLanguages()
2624 $ expectedValueEN = ['contact ' => 'Mobile ' ];
2725 $ expectedValueES = ['contact ' => 'Movil ' ];
2826
29- $ this ->artisan ('langman:rename ' , ['key ' => 'user.mobile ' , 'as ' => 'contact ' ]);
27+ $ this ->artisan ('langman:rename ' , ['oldKey ' => 'user.mobile ' , 'newKey ' => 'contact ' ]);
28+
29+ $ newValueEN = (array ) include $ this ->app ['config ' ]['langman.path ' ].'/en/user.php ' ;
30+ $ newValueES = (array ) include $ this ->app ['config ' ]['langman.path ' ].'/es/user.php ' ;
3031
31- $ newValueEN =(array ) include $ this ->app ['config ' ]['langman.path ' ].'/en/user.php ' ;
32- $ newValueES =(array ) include $ this ->app ['config ' ]['langman.path ' ].'/es/user.php ' ;
3332 $ this ->assertEquals ($ expectedValueEN , $ newValueEN );
3433 $ this ->assertEquals ($ expectedValueES , $ newValueES );
3534 }
@@ -43,10 +42,11 @@ public function testRenameANestedKeyValueForAllLanguages()
4342 $ expectedValueEN = ['contact ' => ['mobile ' => 'Mobile ' ]];
4443 $ expectedValueES = ['contact ' => ['mobile ' => 'Movil ' ]];
4544
46- $ this ->artisan ('langman:rename ' , ['key ' => 'user.contact.cellphone ' , 'as ' => 'mobile ' ]);
45+ $ this ->artisan ('langman:rename ' , ['oldKey ' => 'user.contact.cellphone ' , 'newKey ' => 'mobile ' ]);
4746
48- $ newValueEN =(array ) include $ this ->app ['config ' ]['langman.path ' ].'/en/user.php ' ;
49- $ newValueES =(array ) include $ this ->app ['config ' ]['langman.path ' ].'/es/user.php ' ;
47+ $ newValueEN = (array ) include $ this ->app ['config ' ]['langman.path ' ].'/en/user.php ' ;
48+
49+ $ newValueES = (array ) include $ this ->app ['config ' ]['langman.path ' ].'/es/user.php ' ;
5050 $ this ->assertEquals ($ expectedValueEN , $ newValueEN );
5151 $ this ->assertEquals ($ expectedValueES , $ newValueES );
5252 }
@@ -61,10 +61,10 @@ public function testRenameOfANestedKeyValueForAllLanguagesInAnyDepth()
6161 $ expectedValueEN = ['contact ' => ['mobile ' => 'Mobile ' , 'others ' => ['mail ' => 'E-mail ' ]]];
6262 $ expectedValueES = ['contact ' => ['mobile ' => 'Movil ' , 'others ' => ['mail ' => 'Correo electronico ' ]]];
6363
64- $ this ->artisan ('langman:rename ' , ['key ' => 'user.contact.others.msn ' , 'as ' => 'mail ' ]);
64+ $ this ->artisan ('langman:rename ' , ['oldKey ' => 'user.contact.others.msn ' , 'newKey ' => 'mail ' ]);
6565
66- $ newValueEN =(array ) include $ this ->app ['config ' ]['langman.path ' ].'/en/user.php ' ;
67- $ newValueES =(array ) include $ this ->app ['config ' ]['langman.path ' ].'/es/user.php ' ;
66+ $ newValueEN = (array ) include $ this ->app ['config ' ]['langman.path ' ].'/en/user.php ' ;
67+ $ newValueES = (array ) include $ this ->app ['config ' ]['langman.path ' ].'/es/user.php ' ;
6868 $ this ->assertEquals ($ expectedValueEN , $ newValueEN );
6969 $ this ->assertEquals ($ expectedValueES , $ newValueES );
7070 }
@@ -85,29 +85,15 @@ public function testRenameCommandShowViewFilesAffectedForTheChange()
8585 mkdir (__DIR__ .'/views_temp/users ' );
8686 file_put_contents (__DIR__ .'/views_temp/users/index.blade.php ' , "{{ trans('users.name') }} {{ trans('users.city') }} {{ trans('users.name') }} " );
8787
88- $ this ->artisan ('langman:rename ' , ['key ' => 'users.name ' , 'as ' => 'username ' ]);
88+ $ this ->artisan ('langman:rename ' , ['oldKey ' => 'users.name ' , 'newKey ' => 'username ' ]);
8989
9090 array_map ('unlink ' , glob (__DIR__ .'/views_temp/users/index.blade.php ' ));
9191 array_map ('rmdir ' , glob (__DIR__ .'/views_temp/users ' ));
9292 array_map ('unlink ' , glob (__DIR__ .'/views_temp/users.blade.php ' ));
9393
94- $ this ->assertContains ("2 views files has been affected. \n " , $ this ->consoleOutput ());
95- $ this ->assertRegExp ('/Times (?:.*)View File/ ' , $ this ->consoleOutput ());
94+ $ this ->assertContains ("Renamed key was found in 2 file(s). " , $ this ->consoleOutput ());
95+ $ this ->assertRegExp ('/Encounters (?:.*)File/ ' , $ this ->consoleOutput ());
9696 $ this ->assertRegExp ('/1(?:.*)users\.blade\.php/ ' , $ this ->consoleOutput ());
9797 $ this ->assertRegExp ('/2(?:.*)users( \\\|\/)index\.blade\.php/ ' , $ this ->consoleOutput ());
9898 }
99-
100- public function testThrowErrorMessageForInvalidKeyArgument ()
101- {
102- $ this ->artisan ('langman:rename ' , ['key ' => 'name ' , 'as ' => 'username ' ]);
103-
104- $ this ->assertContains ('Invalid <key> argument format! Pls check and try again. ' , $ this ->consoleOutput ());
105- }
106-
107- public function testThrowErrorMessageForInvalidAsArgument ()
108- {
109- $ this ->artisan ('langman:rename ' , ['key ' => 'user.name ' , 'as ' => 'user.username ' ]);
110-
111- $ this ->assertContains ('Invalid <as> argument format! Pls check and try again. ' , $ this ->consoleOutput ());
112- }
11399}
0 commit comments