Completed
Push — master ( db382d...b26fd3 )
by Chris
02:36
created

DiffrentTextfileCSRTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 22.58 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 2
Metric Value
wmc 8
c 4
b 1
f 2
lcom 1
cbo 2
dl 14
loc 62
ccs 40
cts 40
cp 1
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A checkresponse() 0 4 1
A testWithEmptyresponse() 0 6 1
A testWithTrailingReturn() 0 6 1
A testWithJustSH1() 0 6 1
A testWithSH1AndComdoText() 7 7 1
A testWithSH1AndComdoTextNoTrailingReturn() 7 7 1
A testWithSH1AndComdoTextAndNewLine() 0 7 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
 * @author     Chris Hilsdon <[email protected]>
4
 * @package    ComodoDecodeCSR
5
 * @copyright  2016 Xigen
6
 * @license    GNU General Public License v3
7
 * @link       https://github.com/XigenChris/ComodoDecodeCSR
8
 */
9
10
namespace Xigen\Tests;
11
12
use Xigen\ComodoDecodeCSR;
13
14
class DiffrentTextfileCSRTest extends XigenUnit
15
{
16
    protected $ComodoDecodeCSR;
17
    protected $Hashes;
18
19 6
    public function setUp()
20
    {
21 6
        $this->ComodoDecodeCSR = new ComodoDecodeCSR();
22 6
        $this->ComodoDecodeCSR->setCSR($this->loadTestCSR());
23 6
        $this->Hashes = $this->ComodoDecodeCSR->fetchHashes();
24 6
    }
25
26 6
    private function checkresponse($response)
27
    {
28 6
        return $this->ComodoDecodeCSR->checkDVC($response);
29
    }
30
31 1
    public function testWithEmptyresponse()
32
    {
33 1
        $response = "";
34 1
        $test = $this->checkresponse($response);
35 1
        $this->assertFalse($test);
36 1
    }
37
38 1
    public function testWithTrailingReturn()
39
    {
40 1
        $response = "\n";
41 1
        $test = $this->checkresponse($response);
42 1
        $this->assertFalse($test);
43 1
    }
44
45 1
    public function testWithJustSH1()
46
    {
47 1
        $response = $this->validSHA1 . "\n";
48 1
        $test = $this->checkresponse($response);
49 1
        $this->assertFalse($test);
50 1
    }
51
52 1 View Code Duplication
    public function testWithSH1AndComdoText()
53
    {
54 1
        $response = $this->validSHA1 . "\n";
55 1
        $response .= "comodoca.com\n";
56 1
        $test = $this->checkresponse($response);
57 1
        $this->assertTrue($test);
58 1
    }
59
60 1 View Code Duplication
    public function testWithSH1AndComdoTextNoTrailingReturn()
61
    {
62 1
        $response = $this->validSHA1 . "\n";
63 1
        $response .= "comodoca.com";
64 1
        $test = $this->checkresponse($response);
65 1
        $this->assertTrue($test);
66 1
    }
67
68 1
    public function testWithSH1AndComdoTextAndNewLine()
69
    {
70 1
        $response = $this->validSHA1 . "\n";
71 1
        $response .= "comodoca.com\n\n";
72 1
        $test = $this->checkresponse($response);
73 1
        $this->assertTrue($test);
74 1
    }
75
}
76