MethodNumberOfTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 1 Features 3
Metric Value
wmc 2
c 4
b 1
f 3
lcom 1
cbo 2
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testRuleNoTest() 0 8 1
A testMethodNumberOfRule() 0 9 1
1
<?php
2
3
namespace MS\PHPMD\Tests\Functional\Test;
4
5
use MS\PHPMD\Tests\Functional\AbstractProcessTest;
6
7
/**
8
 * Class MethodNumberOfTest
9
 *
10
 * @package MS\PHPMD\Tests\Functional\Test
11
 */
12
class MethodNumberOfTest extends AbstractProcessTest
13
{
14
    /**
15
     * @covers MS\PHPMD\Rule\Test\MethodNumberOfAsserts
16
     * @covers MS\PHPMD\Rule\Test\MethodNumberOfMocks
17
     * @covers MS\PHPMD\Rule\Test\AbstractMethodNumberOf
18
     * @covers MS\PHPMD\Rule\Test\AbstractTestRule
19
     */
20
    public function testMethodNumberOfRule()
21
    {
22
        $output = $this
23
            ->runPhpmd('Tests/Test.php', 'test.xml')
24
            ->getOutput();
25
26
        $this->assertContains('Tests/Test.php:37	4 mocks are found in this test. Try to reduce the mocks to 3 or less.', $output);
27
        $this->assertContains('Tests/Test.php:52	6 asserts are found in this test. Try to reduce the asserts to 5 or less.', $output);
28
    }
29
30
    /**
31
     * @covers MS\PHPMD\Rule\Test\MethodNumberOfAsserts
32
     * @covers MS\PHPMD\Rule\Test\MethodNumberOfMocks
33
     * @covers MS\PHPMD\Rule\Test\AbstractMethodNumberOf
34
     * @covers MS\PHPMD\Rule\Test\AbstractTestRule
35
     */
36
    public function testRuleNoTest()
37
    {
38
        $output = $this
39
            ->runPhpmd('Entity/Entity.php', 'test.xml')
40
            ->getOutput();
41
42
        $this->assertEmpty(trim($output));
43
    }
44
}
45