@@ -22,13 +22,14 @@ public function testCommandOutput()
2222 ]);
2323
2424 $ command = m::mock ('\Themsaid\Langman\Commands\MissingCommand[ask] ' , [$ manager ]);
25- $ command ->shouldReceive ('ask ' )->once ()->with ('/user\.age:nl/ ' )->andReturn ('fill_age ' );
26- $ command ->shouldReceive ('ask ' )->once ()->with ('/product\.name:en/ ' )->andReturn ('fill_name ' );
27- $ command ->shouldReceive ('ask ' )->once ()->with ('/product\.color:nl/ ' )->andReturn ('fill_color ' );
28- $ command ->shouldReceive ('ask ' )->once ()->with ('/product\.size:nl/ ' )->andReturn ('fill_size ' );
29- $ command ->shouldReceive ('ask ' )->once ()->with ('/missing\.missing\.id:nl/ ' )->andReturn ('fill_missing_id ' );
30- $ command ->shouldReceive ('ask ' )->once ()->with ('/missing\.missing\.price:en/ ' )->andReturn ('fill_missing_price ' );
31- $ command ->shouldReceive ('ask ' )->once ()->with ('/missing\.missing\.price:nl/ ' )->andReturn ('fill_missing_price ' );
25+ $ command ->shouldReceive ('getDefaultValueFor ' )->times (7 )->with (m::any ())->andReturn (null );
26+ $ command ->shouldReceive ('ask ' )->once ()->with ('/user\.age:nl/ ' , null )->andReturn ('fill_age ' );
27+ $ command ->shouldReceive ('ask ' )->once ()->with ('/product\.name:en/ ' , null )->andReturn ('fill_name ' );
28+ $ command ->shouldReceive ('ask ' )->once ()->with ('/product\.color:nl/ ' , null )->andReturn ('fill_color ' );
29+ $ command ->shouldReceive ('ask ' )->once ()->with ('/product\.size:nl/ ' , null )->andReturn ('fill_size ' );
30+ $ command ->shouldReceive ('ask ' )->once ()->with ('/missing\.missing\.id:nl/ ' , null )->andReturn ('fill_missing_id ' );
31+ $ command ->shouldReceive ('ask ' )->once ()->with ('/missing\.missing\.price:en/ ' , null )->andReturn ('fill_missing_price ' );
32+ $ command ->shouldReceive ('ask ' )->once ()->with ('/missing\.missing\.price:nl/ ' , null )->andReturn ('fill_missing_price ' );
3233
3334 $ this ->app ['artisan ' ]->add ($ command );
3435 $ this ->artisan ('langman:missing ' );
@@ -47,4 +48,44 @@ public function testCommandOutput()
4748 $ this ->assertEquals ('fill_missing_price ' , $ missingNLFile ['missing ' ]['price ' ]);
4849 $ this ->assertEquals ('fill_missing_price ' , $ missingENFile ['missing ' ]['price ' ]);
4950 }
51+
52+ public function testAllowSeeTranslationInDefaultLanguage ()
53+ {
54+ $ this ->app ['config ' ]->set ('app.locale ' , 'en ' );
55+ $ this ->createTempFiles ([
56+ 'en ' => [
57+ 'user ' => "<?php \n return ['name' => 'Name', 'age' => 'Age']; " ,
58+ ],
59+ 'nl ' => [
60+ 'user ' => "<?php \n return ['name' => 'Naam']; " ,
61+ ],
62+ ]);
63+ $ manager = $ this ->app [Manager::class];
64+ $ command = m::mock ('\Themsaid\Langman\Commands\MissingCommand[ask] ' , [$ manager ]);
65+ $ command ->shouldReceive ('getDefaultValueFor ' )->once ()->with ('/user\.age/ ' )->andReturn ('en:Age ' );
66+ $ command ->shouldReceive ('ask ' )->once ()->with ('/<fg=yellow>user\.age:nl<\/> translation/ ' , '/en:Age/ ' );
67+ $ this ->app ['artisan ' ]->add ($ command );
68+
69+ $ this ->artisan ('langman:missing ' , ['--default ' => true ]);
70+ }
71+
72+ public function testThrowDefaultMessageWhenLanguageFileIsNotFound ()
73+ {
74+ $ this ->app ['config ' ]->set ('app.locale ' , 'es ' );
75+ $ this ->createTempFiles ([
76+ 'en ' => [
77+ 'user ' => "<?php \n return ['name' => 'Name', 'age' => 'Age']; " ,
78+ ],
79+ 'nl ' => [
80+ 'user ' => "<?php \n return ['name' => 'Naam']; " ,
81+ ],
82+ ]);
83+ $ manager = $ this ->app [Manager::class];
84+ $ command = m::mock ('\Themsaid\Langman\Commands\MissingCommand[ask] ' , [$ manager ]);
85+ $ command ->shouldReceive ('getDefaultValueFor ' )->once ()->with ('/user\.age/ ' )->andReturn ("Sorry. File Language not exists for default locale. " );
86+ $ command ->shouldReceive ('ask ' )->once ()->with ('/<fg=yellow>user\.age:nl<\/> translation/ ' , '/Sorry\. File Language not exists for default locale\./ ' );
87+ $ this ->app ['artisan ' ]->add ($ command );
88+
89+ $ this ->artisan ('langman:missing ' , ['--default ' => true ]);
90+ }
5091}
0 commit comments