Passed
Push — stable ( bf53fe...29e605 )
by Nuno
06:22
created

DotenvInstallTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 5 1
A it_requires_packages() 0 12 1
A it_copy_stubs() 0 9 1
A addDotenvCommand() 0 8 1
1
<?php
2
3
namespace Tests;
4
5
use Illuminate\Support\Facades\File;
6
use LaravelZero\Framework\Contracts\Providers\Composer;
7
use LaravelZero\Framework\Commands\Component\Vlucas\Phpdotenv\Installer;
8
9
class DotenvInstallTest extends TestCase
10
{
11
    public function tearDown()
12
    {
13
        File::delete(base_path('.env'));
14
        File::delete(base_path('.env.example'));
15
    }
16
17
    /** @test */
18
    public function it_requires_packages(): void
19
    {
20
        $composerMock = $this->createMock(Composer::class);
21
22
        $composerMock->expects($this->once())->method('require')->with('vlucas/phpdotenv');
23
24
        app()->instance(Composer::class, $composerMock);
25
26
        $this->app->add(app(Installer::class));
27
28
        $this->app->call('install:dotenv');
29
    }
30
31
    /** @test */
32
    public function it_copy_stubs(): void
33
    {
34
        $this->addDotenvCommand();
35
36
        $this->app->call('install:dotenv');
37
38
        $this->assertTrue(File::exists(base_path('.env')));
39
        $this->assertTrue(File::exists(base_path('.env.example')));
40
    }
41
42
    private function addDotenvCommand(): void
43
    {
44
        $composerMock = $this->createMock(Composer::class);
45
        $composerMock->method('require');
46
        app()->instance(Composer::class, $composerMock);
47
48
        $this->app->add(app(Installer::class));
49
    }
50
}
51