Completed
Push — master ( b949ef...fff8c1 )
by Chris
02:27
created

ComodoDecodeCSRTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 3
Metric Value
wmc 5
c 5
b 0
f 3
lcom 1
cbo 2
dl 0
loc 52
ccs 31
cts 31
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testSettingCSR() 0 11 1
A testGettingHashes() 0 11 1
A testGettingHashesFromInvalidCSR() 0 7 1
A testCheckingInstalled() 0 9 1
1
<?php
2
/**
3
* @author Chris Hilsdon <[email protected]>
4
*/
5
namespace Xigen\Tests;
6
7
use Xigen\ComodoDecodeCSR;
8
9
class ComodoDecodeCSRTest extends XigenUnit
10
{
11
    private $validMD5 = "98EB197EF83F7A9EB736ED7CEBD413CE";
12
    private $validSHA1 = "DA9C72B6F6BCB05772BF8543E19D1A41B0210E84";
13
14 4
    public function setUp()
15
    {
16 4
        $this->ComodoDecodeCSR = new ComodoDecodeCSR();
17 4
    }
18
19 1
    public function testSettingCSR()
20
    {
21
        //Load the test CSR
22 1
        $csr = $this->loadTestCSR();
23 1
        $this->ComodoDecodeCSR->setCSR($csr);
24 1
        $this->assertSame(
25 1
            $csr,
26 1
            $this->ComodoDecodeCSR->getCSR(),
27
            "Unable to set the CSR via ->setCSR()"
28 1
        );
29 1
    }
30
31 3
    public function testGettingHashes()
32
    {
33 1
        $this->ComodoDecodeCSR->setCSR($this->loadTestCSR());
34 1
        $Hashes = $this->ComodoDecodeCSR->fetchHashes();
35
36 1
        $this->assertSame($this->validMD5, $Hashes["md5"], "md5 didn't match the correct value");
37 1
        $this->assertSame($this->validMD5, $this->ComodoDecodeCSR->getMD5(), "md5 didn't match the correct value");
38
39 3
        $this->assertSame($this->validSHA1, $Hashes["sha1"], "sha1 didn't match the correct value");
40 1
        $this->assertSame($this->validSHA1, $this->ComodoDecodeCSR->getSHA1(), "sha1 didn't match the correct value");
41 1
    }
42
43 1
    public function testGettingHashesFromInvalidCSR()
44
    {
45 1
        $Hashes = $this->ComodoDecodeCSR->fetchHashes();
46
47 1
        $this->assertSame($Hashes["md5"], '', "a md5 was set");
48 1
        $this->assertSame($Hashes["sha1"], '', "a sha1 was set");
49 1
    }
50
51 1
    public function testCheckingInstalled()
52
    {
53 1
        $csr = $this->loadTestCSR();
54 1
        $this->ComodoDecodeCSR->setCSR($csr);
55 1
        $this->ComodoDecodeCSR->fetchHashes();
56 1
        $Installed = $this->ComodoDecodeCSR->checkInstalled();
57
58 1
        $this->assertTrue($Installed);
59 1
    }
60
}
61