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\TestAsset; |
22
|
|
|
|
23
|
|
|
use AmericanExpress\HyperledgerFabricClient\Proposal\ResponseCollection; |
24
|
|
|
use AmericanExpress\HyperledgerFabricClient\Proposal\ProposalProcessorInterface; |
25
|
|
|
use AmericanExpress\HyperledgerFabricClient\Transaction\TransactionOptions; |
26
|
|
|
use Hyperledger\Fabric\Protos\Peer\Proposal; |
27
|
|
|
|
28
|
|
|
class MockProposalProcessor implements ProposalProcessorInterface |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @var Proposal $proposal |
32
|
|
|
*/ |
33
|
|
|
private $proposal; |
34
|
|
|
/** |
35
|
|
|
* @var TransactionOptions $options |
36
|
|
|
*/ |
37
|
|
|
private $options; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var ResponseCollection $returnValue |
41
|
|
|
*/ |
42
|
|
|
private $returnValue; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* MockProposalProcessor constructor. |
46
|
|
|
* @param ResponseCollection $returnValue |
47
|
|
|
*/ |
48
|
|
|
public function __construct(ResponseCollection $returnValue = null) |
49
|
|
|
{ |
50
|
|
|
$this->returnValue = $returnValue !== null ? $returnValue : new ResponseCollection(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param Proposal $proposal |
55
|
|
|
* @param TransactionOptions $options |
56
|
|
|
* @return ResponseCollection |
57
|
|
|
*/ |
58
|
|
|
public function processProposal(Proposal $proposal, TransactionOptions $options): ResponseCollection |
59
|
|
|
{ |
60
|
|
|
$this->proposal = $proposal; |
61
|
|
|
$this->options = $options; |
62
|
|
|
|
63
|
|
|
return $this->returnValue; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return Proposal |
68
|
|
|
*/ |
69
|
|
|
public function getProposal() |
70
|
|
|
{ |
71
|
|
|
return $this->proposal; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return TransactionOptions |
76
|
|
|
*/ |
77
|
|
|
public function getTransactionOptions() |
78
|
|
|
{ |
79
|
|
|
return $this->options; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|