Completed
Push — stable ( 386c57...2cb6a4 )
by Nuno
02:05
created

DotenvInstallTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 25.81 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 5
dl 8
loc 31
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 5 1
A it_requires_packages() 8 8 1
A it_copy_stubs() 0 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Tests;
4
5
use Illuminate\Support\Facades\File;
6
use Illuminate\Support\Facades\Artisan;
7
use LaravelZero\Framework\Contracts\Providers\Composer;
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 View Code Duplication
    public function it_requires_packages(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        $composerMock = $this->createMock(Composer::class);
21
        $composerMock->expects($this->once())->method('require')->with('vlucas/phpdotenv');
22
        $this->app->instance(Composer::class, $composerMock);
23
24
        Artisan::call('app:install', ['component' => 'dotenv']);
25
    }
26
27
    /** @test */
28
    public function it_copy_stubs(): void
29
    {
30
        $composerMock = $this->createMock(Composer::class);
31
        $composerMock->expects($this->once())->method('require')->with('vlucas/phpdotenv');
32
        $this->app->instance(Composer::class, $composerMock);
33
34
        Artisan::call('app:install', ['component' => 'dotenv']);
35
36
        $this->assertTrue(File::exists(base_path('.env')));
37
        $this->assertTrue(File::exists(base_path('.env.example')));
38
    }
39
}
40