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

testGettingHashesFromInvalidCSR()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 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