Completed
Push — master ( ed4843...c0d0bb )
by Vincenzo
02:12
created

CreateSeederCommandTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 6 6 2
A testItCreatesASeederFile() 9 9 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
4
use App\Lib\Helpers\TextFormatter;
5
use App\Lib\Slime\Console\Commands\CreateSeederCommand;
6
7 View Code Duplication
class CreateSeederCommandTest extends PHPUnit_Framework_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...
8
{
9
    private $name = 'test_seeder';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
10
    private $seederPath = 'database/seeds/';
11
    private $filesCreated = [];
12
13
    public function tearDown()
14
    {
15
        foreach ($this->filesCreated as $file) {
16
            unlink($file);
17
        }
18
    }
19
20
    /**
21
     * @group Novice
22
     * @group Commands
23
     * @group CreateSeeder
24
     */
25
    public function testItCreatesASeederFile()
26
    {
27
        $command = new CreateSeederCommand([$this->name]);
28
        $result = $command->run();
29
        $this->assertEquals(0, $result);
30
        $files = glob($this->seederPath . '*' . TextFormatter::snakeToCamelCase($this->name) . '.php');
31
        $this->assertNotEmpty($files);
32
        $this->filesCreated = array_merge($this->filesCreated, $files);
33
    }
34
35
}
36