Passed
Push — master ( 21c505...12ca40 )
by Sebastian
02:34
created

UseImperativeMoodTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 25
loc 25
c 0
b 0
f 0
rs 10

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
 * This file is part of CaptainHook.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace sebastianfeldmann\CaptainHook\Hook\Message\Validator\Rule;
11
12
use sebastianfeldmann\CaptainHook\Git\CommitMessage;
13
14
class UseImperativeMoodTest extends \PHPUnit_Framework_TestCase
15
{
16
    /**
17
     * Tests UseImperativeMood::pass
18
     */
19
    public function testPassSuccess()
20
    {
21
        $msg  = new CommitMessage('Foo bar baz');
22
        $rule = new UseImperativeMood();
23
        $this->assertTrue($rule->pass($msg));
24
    }
25
26
    /**
27
     * Tests UseImperativeMood::pass
28
     */
29
    public function testPassFail()
30
    {
31
        $msg  = new CommitMessage('Added some something');
32
        $rule = new UseImperativeMood();
33
        $this->assertFalse($rule->pass($msg));
34
35
        $hint = $rule->getHint();
36
        $this->assertTrue((bool) strpos($hint, 'imperative'));
37
    }
38
}
39