Completed
Push — master ( 8110dc...01b890 )
by Robbie
01:10
created

ChildrenCommandTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTestCommand() 4 4 1
A testExecute() 13 13 1
A testConfigure() 4 4 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 SilverLeague\Console\Tests\Command\Object;
4
5
use SilverLeague\Console\Command\Object\ChildrenCommand;
6
use SilverLeague\Console\Tests\Command\AbstractCommandTest;
7
use Symfony\Component\Console\Tester\CommandTester;
8
9
/**
10
 * @coversDefaultClass \SilverLeague\Console\Command\Object\ChildrenCommand
11
 * @package silverstripe-console
12
 * @author  Robbie Averill <[email protected]>
13
 */
14 View Code Duplication
class ChildrenCommandTest extends AbstractCommandTest
1 ignored issue
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...
15
{
16
    /**
17
     * {@inheritDoc}
18
     */
19
    public function getTestCommand()
20
    {
21
        return 'object:children';
22
    }
23
24
    /**
25
     * Ensure that the Injector's class resolution is returned for a given Object
26
     *
27
     * @covers ::execute
28
     */
29
    public function testExecute()
30
    {
31
        $tester = new CommandTester($this->command);
32
        $tester->execute(
33
            [
34
                'command' => $this->command->getName(),
35
                'object'  => "SilverStripe\Dev\BuildTask"
36
            ]
37
        );
38
39
        $output = $tester->getDisplay();
40
        $this->assertContains("SilverStripe\Dev\Tasks\CleanupTestDatabasesTask", $output);
41
    }
42
43
    /**
44
     * Ensure that the InputArgument for the object is added
45
     *
46
     * @covers ::configure
47
     */
48
    public function testConfigure()
49
    {
50
        $this->assertTrue($this->command->getDefinition()->hasArgument('object'));
51
    }
52
}
53