1 | <?php namespace Nwidart\Modules\Tests; |
||
6 | class ModuleTest extends BaseTestCase |
||
7 | { |
||
8 | /** |
||
9 | * @var Module |
||
10 | */ |
||
11 | private $module; |
||
12 | |||
13 | public function setUp() |
||
14 | { |
||
15 | parent::setUp(); |
||
16 | $this->module = new Module($this->app, 'Recipe', __DIR__ . '/stubs/Recipe'); |
||
17 | } |
||
18 | |||
19 | /** @test */ |
||
20 | public function it_gets_module_name() |
||
21 | { |
||
22 | $this->assertEquals('Recipe', $this->module->getName()); |
||
23 | } |
||
24 | |||
25 | /** @test */ |
||
26 | public function it_gets_lowercase_module_name() |
||
27 | { |
||
28 | $this->assertEquals('recipe', $this->module->getLowerName()); |
||
29 | } |
||
30 | |||
31 | /** @test */ |
||
32 | public function it_gets_studly_name() |
||
33 | { |
||
34 | $this->assertEquals('Recipe', $this->module->getName()); |
||
35 | } |
||
36 | |||
37 | /** @test */ |
||
38 | public function it_gets_module_description() |
||
39 | { |
||
40 | $this->assertEquals('recipe module', $this->module->getDescription()); |
||
41 | } |
||
42 | |||
43 | /** @test */ |
||
44 | public function it_gets_module_alias() |
||
45 | { |
||
46 | $this->assertEquals('recipe', $this->module->getAlias()); |
||
47 | } |
||
48 | |||
49 | /** @test */ |
||
50 | public function it_gets_module_path() |
||
51 | { |
||
52 | $this->assertEquals(__DIR__ . '/stubs/Recipe', $this->module->getPath()); |
||
53 | } |
||
54 | |||
55 | /** @test */ |
||
56 | public function it_loads_module_translations() |
||
57 | { |
||
58 | $this->module->boot(); |
||
59 | |||
60 | $this->assertEquals('Recipe', trans('recipe::recipes.title.recipes')); |
||
61 | } |
||
62 | |||
63 | /** @test */ |
||
64 | public function it_reads_module_json_files() |
||
65 | { |
||
66 | $jsonModule = $this->module->json(); |
||
67 | $composerJson = $this->module->json('composer.json'); |
||
68 | |||
69 | $this->assertInstanceOf(Json::class, $jsonModule); |
||
70 | $this->assertEquals('0.1', $jsonModule->get('version')); |
||
71 | $this->assertInstanceOf(Json::class, $composerJson); |
||
72 | $this->assertEquals('asgard-module', $composerJson->get('type')); |
||
73 | } |
||
74 | |||
75 | /** @test */ |
||
76 | public function it_reads_key_from_module_json_file_via_helper_method() |
||
77 | { |
||
78 | $this->assertEquals('Recipe', $this->module->get('name')); |
||
79 | $this->assertEquals('0.1', $this->module->get('version')); |
||
80 | $this->assertEquals('my default', $this->module->get('some-thing-non-there', 'my default')); |
||
81 | } |
||
82 | |||
83 | /** @test */ |
||
84 | public function it_reads_key_from_composer_json_file_via_helper_method() |
||
85 | { |
||
86 | $this->assertEquals('nwidart/recipe', $this->module->getComposerAttr('name')); |
||
87 | } |
||
88 | |||
89 | /** @test */ |
||
90 | public function it_casts_module_to_string() |
||
91 | { |
||
92 | $this->assertEquals('Recipe', (string) $this->module); |
||
93 | } |
||
94 | |||
95 | /** @test */ |
||
96 | public function it_module_status_check() |
||
97 | { |
||
98 | $this->assertTrue($this->module->isStatus(1)); |
||
99 | $this->assertFalse($this->module->isStatus(0)); |
||
100 | } |
||
101 | |||
102 | /** @test */ |
||
103 | public function it_checks_module_enabled_status() |
||
104 | { |
||
105 | $this->assertTrue($this->module->enabled()); |
||
106 | $this->assertTrue($this->module->active()); |
||
107 | $this->assertFalse($this->module->notActive()); |
||
108 | $this->assertFalse($this->module->disabled()); |
||
109 | } |
||
110 | } |
||
111 |