PluginProbe ʕ •ᴥ•ʔ
ShareThis Dashboard for Google Analytics / trunk
ShareThis Dashboard for Google Analytics vtrunk
3.3.2 trunk 1.0.7 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.5 2.3.5 2.3.6 2.3.7 2.3.8 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.0.0 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3.0 3.3.1
googleanalytics / lib / analytics-admin / vendor / google / gax / src / Testing / MockGrpcTransport.php
googleanalytics / lib / analytics-admin / vendor / google / gax / src / Testing Last commit date
GeneratedTest.php 3 years ago MessageAwareArrayComparator.php 3 years ago MessageAwareExporter.php 3 years ago MockBidiStreamingCall.php 3 years ago MockClientStreamingCall.php 3 years ago MockGrpcTransport.php 3 years ago MockRequest.php 3 years ago MockRequestBody.php 3 years ago MockResponse.php 3 years ago MockServerStreamingCall.php 3 years ago MockStatus.php 3 years ago MockStubTrait.php 3 years ago MockTransport.php 3 years ago MockUnaryCall.php 3 years ago ProtobufGPBEmptyComparator.php 3 years ago ProtobufMessageComparator.php 3 years ago ReceivedRequest.php 3 years ago SerializationTrait.php 3 years ago mocks.proto 3 years ago
MockGrpcTransport.php
142 lines
1 <?php
2 /*
3 * Copyright 2018 Google LLC
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 namespace Google\ApiCore\Testing;
34
35 use Google\ApiCore\Transport\GrpcTransport;
36 use Grpc\ChannelCredentials;
37
38 /**
39 * @internal
40 */
41 class MockGrpcTransport extends GrpcTransport
42 {
43 private $requestArguments;
44 private $mockCall;
45
46 /**
47 * @param mixed $mockCall
48 */
49 public function __construct($mockCall = null)
50 {
51 $this->mockCall = $mockCall;
52 $opts = ['credentials' => ChannelCredentials::createSsl()];
53 parent::__construct('', $opts);
54 }
55
56 /**
57 * @param string $method
58 * @param array $arguments
59 * @param callable $deserialize
60 */
61 protected function _simpleRequest(
62 $method,
63 $arguments,
64 $deserialize,
65 array $metadata = [],
66 array $options = []
67 ) {
68 $this->logCall($method, $deserialize, $metadata, $options, $arguments);
69 return $this->mockCall;
70 }
71
72 /**
73 * @param string $method
74 * @param callable $deserialize
75 */
76 protected function _clientStreamRequest(
77 $method,
78 $deserialize,
79 array $metadata = [],
80 array $options = []
81 ) {
82 $this->logCall($method, $deserialize, $metadata, $options);
83 return $this->mockCall;
84 }
85
86 /**
87 * @param string $method
88 * @param array $arguments
89 * @param callable $deserialize
90 */
91 protected function _serverStreamRequest(
92 $method,
93 $arguments,
94 $deserialize,
95 array $metadata = [],
96 array $options = []
97 ) {
98 $this->logCall($method, $deserialize, $metadata, $options, $arguments);
99 return $this->mockCall;
100 }
101
102 /**
103 * @param string $method
104 * @param callable $deserialize
105 */
106 protected function _bidiRequest(
107 $method,
108 $deserialize,
109 array $metadata = [],
110 array $options = []
111 ) {
112 $this->logCall($method, $deserialize, $metadata, $options);
113 return $this->mockCall;
114 }
115
116 /**
117 * @param string $method
118 * @param callable $deserialize
119 * @param array $arguments
120 */
121 private function logCall(
122 $method,
123 $deserialize,
124 array $metadata = [],
125 array $options = [],
126 $arguments = null
127 ) {
128 $this->requestArguments = [
129 'method' => $method,
130 'arguments' => $arguments,
131 'deserialize' => $deserialize,
132 'metadata' => $metadata,
133 'options' => $options,
134 ];
135 }
136
137 public function getRequestArguments()
138 {
139 return $this->requestArguments;
140 }
141 }
142