@@ -34,6 +34,22 @@ public function testCommandAsksForConfirmationToCreateFileIfNotFound()
3434 $ this ->artisan ('langman:trans ' , ['key ' => 'users.name ' ]);
3535 }
3636
37+ public function testCommandAsksForConfirmationToCreatePackageFileIfNotFound ()
38+ {
39+ $ this ->createTempFiles ([
40+ 'vendor ' => ['package ' => ['en ' => [], 'sp ' => []]],
41+ ]);
42+
43+ $ manager = $ this ->app [Manager::class];
44+ $ command = m::mock ('\Themsaid\Langman\Commands\TransCommand[confirm] ' , [$ manager ]);
45+ $ command ->shouldReceive ('confirm ' )->once ()->andReturn (true );
46+
47+ $ this ->app ['artisan ' ]->add ($ command );
48+ $ this ->artisan ('langman:trans ' , ['key ' => 'package::file.name ' ]);
49+
50+ $ this ->assertFileNotExists ($ this ->app ['config ' ]['langman.path ' ].'/vendor/package/en/file.php ' );
51+ }
52+
3753 public function testCommandExitsWhenFileNotFoundAndConfirmationFalse ()
3854 {
3955 $ this ->createTempFiles (['en ' => []]);
@@ -84,6 +100,26 @@ public function testCommandAsksForValuePerLanguageAndWriteToFile()
84100 $ this ->assertEquals ('naam ' , $ nlFile ['name ' ]);
85101 }
86102
103+ public function testCommandAsksForValuePerLanguageForPackageAndWriteToFile ()
104+ {
105+ $ this ->createTempFiles ([
106+ 'vendor ' => ['package ' => ['en ' => ['users ' => "<?php \n return []; " ], 'sp ' => ['users ' => "<?php \n return []; " ]]],
107+ ]);
108+
109+ $ manager = $ this ->app [Manager::class];
110+ $ command = m::mock ('\Themsaid\Langman\Commands\TransCommand[ask] ' , [$ manager ]);
111+ $ command ->shouldReceive ('ask ' )->once ()->with ('/users\.name:en/ ' , null )->andReturn ('name ' );
112+ $ command ->shouldReceive ('ask ' )->once ()->with ('/users\.name:sp/ ' , null )->andReturn ('naam ' );
113+
114+ $ this ->app ['artisan ' ]->add ($ command );
115+ $ this ->artisan ('langman:trans ' , ['key ' => 'package::users.name ' ]);
116+
117+ $ enFile = (array ) include $ this ->app ['config ' ]['langman.path ' ].'/vendor/package/en/users.php ' ;
118+ $ nlFile = (array ) include $ this ->app ['config ' ]['langman.path ' ].'/vendor/package/sp/users.php ' ;
119+ $ this ->assertEquals ('name ' , $ enFile ['name ' ]);
120+ $ this ->assertEquals ('naam ' , $ nlFile ['name ' ]);
121+ }
122+
87123 public function testCommandAsksForValuePerLanguageAndUpdatingExistingInFile ()
88124 {
89125 $ this ->createTempFiles ([
0 commit comments