Completed
Push — develop ( 4146c2...e30e33 )
by Chris
35:42
created

ComodoDecodeCSRTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 9
Bugs 0 Features 5
Metric Value
wmc 6
c 9
b 0
f 5
lcom 1
cbo 2
dl 0
loc 61
ccs 38
cts 38
cp 1
rs 10

6 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
A testCheckInstalledFail() 0 9 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 Xigen\ComodoDecodeCSR;
13
14
class ComodoDecodeCSRTest extends XigenUnit
15
{
16
    protected $ComodoDecodeCSR;
17
18 5
    public function setUp()
19
    {
20 5
        $this->ComodoDecodeCSR = new ComodoDecodeCSR();
21 5
    }
22
23 1
    public function testSettingCSR()
24
    {
25
        //Load the test CSR
26 1
        $csr = $this->loadTestCSR();
27 1
        $this->ComodoDecodeCSR->setCSR($csr);
28 1
        $this->assertSame(
29 1
            $csr,
30 1
            $this->ComodoDecodeCSR->getCSR(),
31
            "Unable to set the CSR via ->setCSR()"
32 1
        );
33 1
    }
34
35 1
    public function testGettingHashes()
36
    {
37 1
        $this->ComodoDecodeCSR->setCSR($this->loadTestCSR());
38 1
        $hashes = $this->ComodoDecodeCSR->fetchHashes();
39
40 1
        $this->assertSame($this->validMD5, $hashes["md5"], "md5 didn't match the correct value");
41 1
        $this->assertSame($this->validMD5, $this->ComodoDecodeCSR->getMD5(), "md5 didn't match the correct value");
42
43 1
        $this->assertSame($this->validSHA1, $hashes["sha1"], "sha1 didn't match the correct value");
44 1
        $this->assertSame($this->validSHA1, $this->ComodoDecodeCSR->getSHA1(), "sha1 didn't match the correct value");
45 1
    }
46
47 1
    public function testGettingHashesFromInvalidCSR()
48
    {
49 1
        $hashes = $this->ComodoDecodeCSR->fetchHashes();
50
51 1
        $this->assertSame($hashes["md5"], '', "a md5 was set");
52 1
        $this->assertSame($hashes["sha1"], '', "a sha1 was set");
53 1
    }
54
55 1
    public function testCheckingInstalled()
56
    {
57 1
        $csr = $this->loadTestCSR();
58 1
        $this->ComodoDecodeCSR->setCSR($csr);
59 1
        $this->ComodoDecodeCSR->fetchHashes();
60 1
        $installed = $this->ComodoDecodeCSR->checkInstalled();
61
62 1
        $this->assertTrue($installed);
63 1
    }
64
65 1
    public function testCheckInstalledFail()
66
    {
67 1
        $csr = $this->createFakeCSR();
68 1
        $this->ComodoDecodeCSR->setCSR($csr);
69 1
        $this->ComodoDecodeCSR->fetchHashes();
70 1
        $installed = $this->ComodoDecodeCSR->checkInstalled();
71
72 1
        $this->assertFalse($installed);
73 1
    }
74
}
75