Completed
Push — stable ( 86ecc3...3a45ea )
by Nuno
07:34
created

LoadConfigurationsTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 2
cbo 4
dl 0
loc 46
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_reads_configuration_files() 0 9 1
A it_reads_commands() 0 19 2
A it_allows_hidden_commands() 0 4 1
A it_allows_remove_commands() 0 4 1
1
<?php
2
3
namespace Tests;
4
5
use App\Commands\FakeFooCommand;
6
use App\Commands\FakeDefaultCommand;
7
use App\Commands\FakeRemovedCommand;
8
use App\OtherCommands\FakeOtherCommand;
9
use Illuminate\Support\Facades\Artisan;
10
use App\HiddenCommands\FakeHiddenCommand;
11
12
class LoadConfigurationsTest extends TestCase
13
{
14
    /** @test */
15
    public function it_reads_configuration_files()
16
    {
17
        $this->assertSame('Application', Artisan::getName());
18
        $this->assertSame('Test version', $this->app->version());
19
        $this->assertEquals(
20
            $this->app->environment(),
21
            'development'
22
        );
23
    }
24
25
    /** @test */
26
    public function it_reads_commands()
27
    {
28
        $commands = [
29
            FakeDefaultCommand::class,
30
            FakeFooCommand::class,
31
            FakeOtherCommand::class,
32
            FakeHiddenCommand::class
33
        ];
34
35
        $appCommands = collect(Artisan::all())->map(
36
            function ($command) {
37
                return get_class($command);
38
            }
39
        )->toArray();
40
41
        foreach ($commands as $command) {
42
            $this->assertContains($command, $appCommands);
43
        }
44
    }
45
46
    /** @test */
47
    public function it_allows_hidden_commands()
48
    {
49
        $this->assertTrue(Artisan::all()['fake:hidden']->isHidden());
50
    }
51
52
    /** @test */
53
    public function it_allows_remove_commands()
54
    {
55
        $this->assertArrayNotHasKey('fake:removed', Artisan::all());
56
    }
57
}
58