MethodNumberOfMocksTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 43.59 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 4
Bugs 1 Features 3
Metric Value
wmc 2
c 4
b 1
f 3
lcom 1
cbo 5
dl 17
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMoreMocks() 17 17 1
A getRule() 0 10 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 MS\PHPMD\Tests\Unit\Test;
4
5
use MS\PHPMD\Rule\Test\MethodNumberOfMocks;
6
7
/**
8
 * Class MethodNumberOfMocksTest
9
 *
10
 * @package MS\PHPMD\Tests\Unit\Test
11
 */
12
class MethodNumberOfMocksTest extends AbstractClassTest
13
{
14
    /**
15
     * @covers MS\PHPMD\Rule\Test\MethodNumberOfMocks
16
     * @covers MS\PHPMD\Rule\Test\AbstractMethodNumberOf
17
     * @covers MS\PHPMD\Rule\Test\AbstractTestRule
18
     */
19 View Code Duplication
    public function testMoreMocks()
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...
20
    {
21
        $methodNode = $this->getMethodNode(
22
            self::CLASS_NAME,
23
            'testBar',
24
            ['MethodPostfix' => array_merge(
25
                array_fill(0, 3, $this->getNode('mock')),
26
                array_fill(0, 1, $this->getNode('getMock'))
27
            )]
28
        );
29
30
        $node = \Mockery::mock('PHPMD\Node\ClassNode');
31
        $node->shouldReceive('getImage')->andReturn(self::CLASS_NAME);
32
        $node->shouldReceive('getMethods')->andReturn([$methodNode]);
33
34
        $this->assertRule($node, 1);
35
    }
36
37
    /**
38
     * @return MethodNumberOfMocks
39
     */
40
    protected function getRule()
41
    {
42
        $rule =  new MethodNumberOfMocks();
43
        $rule->addProperty('number', '3');
44
        $rule->addProperty('names', 'getMock,mock');
45
        $rule->addProperty('delimiter', ',');
46
        $rule->addProperty('match', '1');
47
48
        return $rule;
49
    }
50
}
51