PeerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 11 1
A testProcessChannelProposal() 0 8 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\Peer;
24
use Grpc\UnaryCall;
25
use Hyperledger\Fabric\Protos\Peer\EndorserClient;
26
use Hyperledger\Fabric\Protos\Peer\SignedProposal;
27
use PHPUnit\Framework\TestCase;
28
29
/**
30
 * @covers \AmericanExpress\HyperledgerFabricClient\Peer\Peer
31
 */
32
class PeerTest extends TestCase
33
{
34
    /**
35
     * @var UnaryCall|\PHPUnit_Framework_MockObject_MockObject
36
     */
37
    private $unaryCall;
38
39
    /**
40
     * @var EndorserClient|\PHPUnit_Framework_MockObject_MockObject
41
     */
42
    private $endorserClient;
43
44
    /**
45
     * @var Peer
46
     */
47
    private $sut;
48
49
    protected function setUp()
50
    {
51
        $this->endorserClient = $this->getMockBuilder(EndorserClient::class)
52
            ->disableOriginalConstructor()
53
            ->getMock();
54
55
        $this->unaryCall = $this->getMockBuilder(UnaryCall::class)
56
            ->disableOriginalConstructor()
57
            ->getMock();
58
59
        $this->sut = new Peer($this->endorserClient);
60
    }
61
    public function testProcessChannelProposal()
62
    {
63
        $this->endorserClient->method('ProcessProposal')
0 ignored issues
show
Bug introduced by
The method method() does not exist on Hyperledger\Fabric\Protos\Peer\EndorserClient. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
        $this->endorserClient->/** @scrutinizer ignore-call */ 
64
                               method('ProcessProposal')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64
            ->willReturn($this->unaryCall);
65
66
        $result = $this->sut->processSignedProposal(new SignedProposal());
67
68
        self::assertSame($this->unaryCall, $result);
69
    }
70
}
71