Completed
Push — master ( d85f7e...9ff25d )
by Nicolas
02:47
created

ModuleGeneratorTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 30.19 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 2
dl 16
loc 53
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A tearDown() 0 5 1
A it_generates_module() 0 7 1
A it_generates_module_folders() 8 8 2
A it_generates_module_files() 8 8 2

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 Nwidart\Modules\Tests;
4
5
class ModuleGeneratorTest extends BaseTestCase
6
{
7
    /**
8
     * @var \Illuminate\Filesystem\Filesystem
9
     */
10
    private $finder;
11
    /**
12
     * @var string
13
     */
14
    private $modulePath;
15
16
    public function setUp()
17
    {
18
        parent::setUp();
19
        $this->modulePath = base_path('modules/Blog');
20
        $this->finder = $this->app['files'];
21
    }
22
23
    public function tearDown()
24
    {
25
        $this->finder->deleteDirectory($this->modulePath);
26
        parent::tearDown();
27
    }
28
29
    /** @test */
30
    public function it_generates_module()
31
    {
32
        $code = $this->artisan('module:make', ['name' => ['Blog']]);
33
34
        $this->assertTrue(is_dir($this->modulePath));
35
        $this->assertSame(0, $code);
36
    }
37
38
    /** @test */
39 View Code Duplication
    public function it_generates_module_folders()
1 ignored issue
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...
40
    {
41
        $this->artisan('module:make', ['name' => ['Blog']]);
42
43
        foreach (config('modules.paths.generator') as $directory) {
44
            $this->assertTrue(is_dir($this->modulePath . '/' . $directory));
45
        }
46
    }
47
48
    /** @test */
49 View Code Duplication
    public function it_generates_module_files()
1 ignored issue
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...
50
    {
51
        $this->artisan('module:make', ['name' => ['Blog']]);
52
53
        foreach (config('modules.stubs.files') as $file) {
54
            $this->assertTrue(is_file($this->modulePath . '/' . $file));
55
        }
56
    }
57
}
58