Completed
Push — master ( 32a55a...fb9711 )
by Mitchel
02:18
created

CertificateTypeTest::itTellsIfItsEqualOrNot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Bunq\Test\Certificate;
4
5
use Bunq\Certificate\CertificateType;
6
use PHPUnit\Framework\TestCase;
7
8
final class CertificateTypeTest extends TestCase
9
{
10
    /**
11
     * @test
12
     */
13
    public function itRepresentsACertificateType()
14
    {
15
        $certificateType = CertificateType::fromString('private.pem');
16
17
        $this->assertInstanceOf(CertificateType::class, $certificateType);
18
        $this->assertEquals($certificateType->toString(), 'private.pem');
19
    }
20
21
    /**
22
     * @test
23
     */
24
    public function itGivesAllTypesAsList()
25
    {
26
        $expected = [
27
            CertificateType::PRIVATE_KEY(),
28
            CertificateType::PUBLIC_KEY(),
29
            CertificateType::BUNQ_SERVER_KEY(),
30
        ];
31
        $result = CertificateType::all();
32
33
        $this->assertEquals($expected, $result);
34
    }
35
36
    /**
37
     * @test
38
     */
39
    public function itGivesAllTypesAsStringList()
40
    {
41
        $expected = [
42
            'private.pem',
43
            'public.pem',
44
            'public_server_key.pem',
45
        ];
46
        $result = CertificateType::allAsString();
47
48
        $this->assertEquals($expected, $result);
49
    }
50
51
    /**
52
     * @test
53
     */
54
    public function itTellsIfItsEqualOrNot()
55
    {
56
        $certificate = CertificateType::PRIVATE_KEY();
57
58
        $this->assertTrue($certificate->equals(CertificateType::PRIVATE_KEY()));
59
        $this->assertFalse($certificate->equals(CertificateType::PUBLIC_KEY()));
60
        $this->assertFalse($certificate->equals(new \stdClass()));
61
        $this->assertFalse($certificate->equals('private key'));
62
    }
63
64
    /**
65
     * @test
66
     * @expectedException \InvalidArgumentException
67
     * @expectedExceptionMessage Invalid certificate type test
68
     */
69
    public function itThrowsAnErrorWhenTypeIsNotKnown()
70
    {
71
        CertificateType::fromString('test');
72
    }
73
}
74