Passed
Push — stable ( 7698e0...f9d7ca )
by Nuno
03:02
created

DatabaseInstallTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
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\Illuminate\Database\Installer;
8
9 View Code Duplication
class DatabaseInstallTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
10
{
11
    public function tearDown()
12
    {
13
        File::delete(config_path('database.php'));
14
        File::delete(database_path('database.sqlite'));
15
        File::delete(database_path('migrations'));
16
        File::delete(database_path('seeds'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php'));
17
    }
18
19
    /** @test */
20
    public function it_requires_packages(): void
21
    {
22
        $composerMock = $this->createMock(Composer::class);
23
24
        $composerMock->expects($this->once())->method('require')->with('illuminate/database "5.5.*"');
25
26
        app()->instance(Composer::class, $composerMock);
27
28
        $this->app->add(app(Installer::class));
29
30
        $this->app->call('install:database');
31
    }
32
33
    /** @test */
34
    public function it_copy_stubs(): void
35
    {
36
        $this->addDatabaseCommand();
37
38
        $this->app->call('install:database');
39
40
        $this->assertTrue(File::exists(config_path('database.php')));
41
        $this->assertTrue(File::exists(database_path('database.sqlite')));
42
        $this->assertTrue(File::exists(database_path('migrations')));
43
        $this->assertTrue(File::exists(database_path('seeds'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php')));
44
    }
45
46
    private function addDatabaseCommand(): void
47
    {
48
        $composerMock = $this->createMock(Composer::class);
49
        $composerMock->method('require');
50
        app()->instance(Composer::class, $composerMock);
51
52
        $this->app->add(app(Installer::class));
53
    }
54
}
55