Completed
Pull Request — master (#33)
by Robbie
03:36
created

LookupCommandTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 17.5 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 4
dl 7
loc 40
rs 10

4 Methods

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