Test Failed
Push — stable ( 535a20...74df7e )
by Nuno
37s
created

ApplicationTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 52
rs 10
c 2
b 0
f 0
wmc 4
lcom 1
cbo 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_binds_core_alias() 0 10 1
B it_configures_using_configuration() 0 25 2
A it_register_service_providers() 0 9 1
1
<?php
2
3
namespace Tests\Unit;
4
5
use Tests\TestCase;
6
use Tests\FakeExtraCommand;
7
use Tests\FakeDefaultCommand;
8
use Illuminate\Container\Container;
9
use Illuminate\Contracts\Config\Repository;
10
11
class ApplicationTest extends TestCase
12
{
13
    /** @test */
14
    public function it_binds_core_alias(): void
15
    {
16
        $container = $this->createApplication()
17
            ->getContainer();
18
19
        $this->assertTrue(Container::getInstance() === $container);
20
        $this->assertTrue($container->make('app') === $container);
21
        $this->assertTrue($container->make(Container::class) === $container);
22
        $this->assertInstanceOf(Repository::class, $container->make('config'));
23
    }
24
25
    /** @test */
26
    public function it_configures_using_configuration()
27
    {
28
        // @todo Test production config.
29
        $app = $this->createApplication();
30
31
        $this->assertTrue($app->getName() === 'Test name');
32
        $this->assertTrue($app->getVersion() === 'Test version');
33
34
        $commands = [
35
            FakeDefaultCommand::class,
36
            FakeExtraCommand::class,
37
        ];
38
39
        $appCommands = collect($app->all())
40
            ->map(
41
                function ($command) {
42
                    return get_class($command);
43
                }
44
            )
45
            ->toArray();
46
47
        foreach ($commands as $command) {
48
            $this->assertTrue(in_array($command, $appCommands));
49
        }
50
    }
51
52
    /** @test */
53
    public function it_register_service_providers()
54
    {
55
        $app = $this->createApplication();
56
57
        $this->assertTrue(
58
            $app->getContainer()
59
                ->make('foo') === 'bar'
60
        );
61
    }
62
}
63