DiffrentTextfileCSRTest::testWithSH1AndComdoText()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 7
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 1
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 GuzzleHttp\Psr7;
13
use GuzzleHttp\Psr7\Response;
14
15
use Xigen\ComodoDecodeCSR;
16
17
class DiffrentTextfileCSRTest extends XigenUnit
18
{
19 6
    protected $ComodoDecodeCSR;
20
    protected $Hashes;
21 6
22 6
    public function setUp()
23 6
    {
24 6
        $this->ComodoDecodeCSR = new ComodoDecodeCSR();
25
        $this->ComodoDecodeCSR->setCSR($this->loadTestCSR());
26 6
        $this->Hashes = $this->ComodoDecodeCSR->fetchHashes();
27
    }
28 6
29
    private function checkresponse($response)
30
    {
31 1
        $stream = Psr7\stream_for($response);
32
        $response = new Response(200, [], $stream);
33 1
        return $this->ComodoDecodeCSR->checkDVC($response);
34 1
    }
35 1
36 1
    public function testWithEmptyresponse()
37
    {
38 1
        $response = "";
39
        $test = $this->checkresponse($response);
40 1
        $this->assertFalse($test);
41 1
    }
42 1
43 1
    public function testWithTrailingReturn()
44
    {
45 1
        $response = "\n";
46
        $test = $this->checkresponse($response);
47 1
        $this->assertFalse($test);
48 1
    }
49 1
50 1
    public function testWithJustSH1()
51
    {
52 1
        $response = $this->validSHA1 . "\n";
53
        $test = $this->checkresponse($response);
54 1
        $this->assertFalse($test);
55 1
    }
56 1
57 1 View Code Duplication
    public function testWithSH1AndComdoText()
58 1
    {
59
        $response = $this->validSHA1 . "\n";
60 1
        $response .= "comodoca.com\n";
61
        $test = $this->checkresponse($response);
62 1
        $this->assertTrue($test);
63 1
    }
64 1
65 1 View Code Duplication
    public function testWithSH1AndComdoTextNoTrailingReturn()
66 1
    {
67
        $response = $this->validSHA1 . "\n";
68 1
        $response .= "comodoca.com";
69
        $test = $this->checkresponse($response);
70 1
        $this->assertTrue($test);
71 1
    }
72 1
73 1
    public function testWithSH1AndComdoTextAndNewLine()
74 1
    {
75
        $response = $this->validSHA1 . "\n";
76
        $response .= "comodoca.com\n\n";
77
        $test = $this->checkresponse($response);
78
        $this->assertTrue($test);
79
    }
80
}
81