1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use JsLocalization\JsLocalizationServiceProvider; |
4
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
5
|
|
|
|
6
|
|
|
class JsLocalizationServiceProviderTest extends Orchestra\Testbench\TestCase |
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
protected function getPackageProviders($app) |
10
|
|
|
{ |
11
|
|
|
return ['JsLocalization\JsLocalizationServiceProvider']; |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
public function testProvidesArray() { |
16
|
|
|
$service = new JsLocalizationServiceProvider($this->app); |
17
|
|
|
|
18
|
|
|
$this->assertEquals( $service->provides(), ['js-localization'] ); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testRegisteredNamespaces() |
22
|
|
|
{ |
23
|
|
|
$this->assertEquals(['en'], Config::get('js-localization.locales')); |
24
|
|
|
$this->assertEquals([], Config::get('js-localization.messages')); |
25
|
|
|
|
26
|
|
|
$this->assertArrayHasKey( |
27
|
|
|
'js-localization', View::getFinder()->getHints(), |
28
|
|
|
'View namespace not registered: js-localization' |
29
|
|
|
); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testRegisteredCommands() |
33
|
|
|
{ |
34
|
|
|
$allCommands = Artisan::all(); |
35
|
|
|
|
36
|
|
|
/** @var \Symfony\Component\Console\Command\Command $command */ |
37
|
|
|
foreach ($allCommands as $command) { |
38
|
|
|
if ($command->getName() === 'js-localization:refresh') { break; } |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$refreshCommand = $command; |
|
|
|
|
42
|
|
|
$this->assertInstanceOf('JsLocalization\Console\RefreshCommand', $refreshCommand); |
43
|
|
|
|
44
|
|
|
$commandTester = new CommandTester($refreshCommand); |
45
|
|
|
$commandTester->execute([]); |
46
|
|
|
$this->assertEquals("Refreshing the message cache...\n", $commandTester->getDisplay()); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testBindings() |
50
|
|
|
{ |
51
|
|
|
$helper = App::make('JsLocalizationHelper'); |
52
|
|
|
$this->assertInstanceOf('JsLocalization\Utils\Helper', $helper); |
53
|
|
|
|
54
|
|
|
$cachingService = App::make('JsLocalizationMessageCachingService'); |
55
|
|
|
$this->assertInstanceOf('JsLocalization\Caching\MessageCachingService', $cachingService); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
It seems like you are relying on a variable being defined by an iteration: