PeerOptionsTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 72
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testTlsCaCerts() 0 7 1
A testFromArray() 0 15 1
A testEvents() 0 7 1
A testServerHostname() 0 7 1
A testName() 0 7 1
A testRequests() 0 7 1
1
<?php
2
3
/**
4
 * Copyright 2017 American Express Travel Related Services Company, Inc.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15
 * or implied. See the License for the specific language governing
16
 * permissions and limitations under the License.
17
 */
18
19
declare(strict_types=1);
20
21
namespace AmericanExpressTest\HyperledgerFabricClient\Peer;
22
23
use AmericanExpress\HyperledgerFabricClient\Peer\PeerOptions;
24
use PHPUnit\Framework\TestCase;
25
26
/**
27
 * @covers \AmericanExpress\HyperledgerFabricClient\Peer\PeerOptions
28
 */
29
class PeerOptionsTest extends TestCase
30
{
31
    /**
32
     * @var PeerOptions
33
     */
34
    private $sut;
35
36
    protected function setUp()
37
    {
38
        $this->sut = new PeerOptions();
39
    }
40
41
    public function testName()
42
    {
43
        self::assertNull($this->sut->getName());
44
45
        $this->sut->setName('peer1');
46
47
        self::assertSame('peer1', $this->sut->getName());
48
    }
49
50
    public function testRequests()
51
    {
52
        self::assertNull($this->sut->getRequests());
53
54
        $this->sut->setRequests('localhost:7051');
55
56
        self::assertSame('localhost:7051', $this->sut->getRequests());
57
    }
58
59
    public function testEvents()
60
    {
61
        self::assertNull($this->sut->getEvents());
62
63
        $this->sut->setEvents('localhost:7053');
64
65
        self::assertSame('localhost:7053', $this->sut->getEvents());
66
    }
67
68
    public function testServerHostname()
69
    {
70
        self::assertNull($this->sut->getServerHostname());
71
72
        $this->sut->setServerHostname('peer0.org1.example.com');
73
74
        self::assertSame('peer0.org1.example.com', $this->sut->getServerHostname());
75
    }
76
77
    public function testTlsCaCerts()
78
    {
79
        self::assertNull($this->sut->getTlsCaCerts());
80
81
        $this->sut->setTlsCaCerts(__FILE__);
82
83
        self::assertSame(__FILE__, $this->sut->getTlsCaCerts());
84
    }
85
86
    public function testFromArray()
87
    {
88
        $sut = new PeerOptions([
89
            'name' => 'peer1',
90
            'requests' => 'localhost:7051',
91
            'events' => 'localhost:7053',
92
            'server-hostname' => 'peer0.org1.example.com',
93
            'tls_cacerts' => __FILE__,
94
        ]);
95
96
        self::assertSame('peer1', $sut->getName());
97
        self::assertSame('localhost:7051', $sut->getRequests());
98
        self::assertSame('localhost:7053', $sut->getEvents());
99
        self::assertSame('peer0.org1.example.com', $sut->getServerHostname());
100
        self::assertSame(__FILE__, $sut->getTlsCaCerts());
101
    }
102
}
103