File tree Expand file tree Collapse file tree 2 files changed +54
-2
lines changed
src/JsLocalization/Console
tests/JsLocalization/console Expand file tree Collapse file tree 2 files changed +54
-2
lines changed Original file line number Diff line number Diff line change 11<?php
22namespace JsLocalization \Console ;
33
4+ use Config ;
45use Illuminate \Console \Command ;
56use JsLocalization \Facades \CachingService ;
67use Symfony \Component \Console \Input \InputOption ;
@@ -22,7 +23,7 @@ class RefreshCommand extends Command
2223 * @var string
2324 */
2425 protected $ description = "Refresh message cache after changing the config file " ;
25-
26+
2627 /**
2728 * Execute the console command.
2829 *
@@ -32,7 +33,13 @@ public function fire()
3233 {
3334 $ this ->line ('Refreshing the message cache... ' );
3435
36+ $ locales = Config::get ('js-localization::config.locales ' );
37+
38+ if (!is_array ($ locales )) {
39+ throw new \Exception ('Please set the "locales" config! See https://github.com/andywer/laravel-js-localization#configuration ' );
40+ }
41+
3542 CachingService::refreshMessageCache ();
3643 }
3744
38- }
45+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Mockery as m ;
4+ use JsLocalization \Console \RefreshCommand ;
5+
6+ class RefreshCommandTest extends TestCase
7+ {
8+
9+ public function setUp ()
10+ {
11+ parent ::setUp ();
12+ }
13+
14+ public function tearDown ()
15+ {
16+ m::close ();
17+
18+ parent ::tearDown ();
19+ }
20+
21+ public function testNoLocalesConfigException ()
22+ {
23+ // Mock Config
24+ Illuminate \Support \Facades \Config::swap ($ config = m::mock ('ConfigMock ' ));
25+
26+ $ config ->shouldReceive ('get ' )->with ('js-localization::config.locales ' )
27+ ->andReturn (null );
28+
29+
30+ $ this ->setExpectedException ('Exception ' );
31+
32+ $ this ->runCommand ();
33+ }
34+
35+ protected function runCommand ()
36+ {
37+ $ cmd = new RefreshCommand ();
38+
39+ $ cmd ->run (
40+ new Symfony \Component \Console \Input \ArrayInput (array ('package ' => 'foo ' )),
41+ new Symfony \Component \Console \Output \NullOutput
42+ );
43+ }
44+
45+ }
You can’t perform that action at this time.
0 commit comments