allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
This commit is contained in:
102
vendor/google/gax/src/Testing/GeneratedTest.php
vendored
Normal file
102
vendor/google/gax/src/Testing/GeneratedTest.php
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2017 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\ApiCore\Serializer;
|
||||
use Google\Protobuf\DescriptorPool;
|
||||
use Google\Protobuf\Internal\Message;
|
||||
use Google\Protobuf\RepeatedField;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract class GeneratedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param mixed $expected
|
||||
* @param mixed $actual
|
||||
*/
|
||||
public function assertProtobufEquals(&$expected, &$actual)
|
||||
{
|
||||
if ($expected === $actual) {
|
||||
// This is not needed but reduces the number of "This test did not perform any assertions" messages
|
||||
$this->assertSame($expected, $actual);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_array($expected) || $expected instanceof RepeatedField) {
|
||||
if (is_array($expected) === is_array($actual)) {
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
$this->assertCount(count($expected), $actual);
|
||||
|
||||
$expectedValues = $this->getValues($expected);
|
||||
$actualValues = $this->getValues($actual);
|
||||
|
||||
for ($i = 0; $i < count($expectedValues); $i++) {
|
||||
$expectedElement = $expectedValues[$i];
|
||||
$actualElement = $actualValues[$i];
|
||||
$this->assertProtobufEquals($expectedElement, $actualElement);
|
||||
}
|
||||
} else {
|
||||
$this->assertEquals($expected, $actual);
|
||||
if ($expected instanceof Message) {
|
||||
$pool = DescriptorPool::getGeneratedPool();
|
||||
$descriptor = $pool->getDescriptorByClassName(get_class($expected));
|
||||
|
||||
$fieldCount = $descriptor->getFieldCount();
|
||||
for ($i = 0; $i < $fieldCount; $i++) {
|
||||
$field = $descriptor->getField($i);
|
||||
$getter = Serializer::getGetter($field->getName());
|
||||
$expectedFieldValue = $expected->$getter();
|
||||
$actualFieldValue = $actual->$getter();
|
||||
$this->assertProtobufEquals($expectedFieldValue, $actualFieldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iterable $field
|
||||
*/
|
||||
private function getValues($field)
|
||||
{
|
||||
return array_values(
|
||||
is_array($field)
|
||||
? $field
|
||||
: iterator_to_array($field)
|
||||
);
|
||||
}
|
||||
}
|
||||
32
vendor/google/gax/src/Testing/MessageAwareArrayComparator.php
vendored
Normal file
32
vendor/google/gax/src/Testing/MessageAwareArrayComparator.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use SebastianBergmann\Comparator\ArrayComparator;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class MessageAwareArrayComparator extends ArrayComparator
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->exporter = new MessageAwareExporter();
|
||||
}
|
||||
}
|
||||
47
vendor/google/gax/src/Testing/MessageAwareExporter.php
vendored
Normal file
47
vendor/google/gax/src/Testing/MessageAwareExporter.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\Protobuf\Internal\Message;
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class MessageAwareExporter extends Exporter
|
||||
{
|
||||
/**
|
||||
* Exports a value into a single-line string
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*
|
||||
* @see \SebastianBergmann\Exporter\Exporter::export
|
||||
*/
|
||||
public function shortenedExport($value)
|
||||
{
|
||||
if (\is_object($value) && $value instanceof Message) {
|
||||
return \sprintf(
|
||||
'%s Object (%s)',
|
||||
\get_class($value),
|
||||
\spl_object_hash($value)
|
||||
);
|
||||
}
|
||||
return parent::shortenedExport($value);
|
||||
}
|
||||
}
|
||||
168
vendor/google/gax/src/Testing/MockBidiStreamingCall.php
vendored
Normal file
168
vendor/google/gax/src/Testing/MockBidiStreamingCall.php
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2016 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\ApiCore\ApiException;
|
||||
use Google\Protobuf\Internal\Message;
|
||||
use Google\Rpc\Code;
|
||||
use Grpc;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* The MockBidiStreamingCall class is used to mock out the \Grpc\BidiStreamingCall class
|
||||
* (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BidiStreamingCall.php)
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MockBidiStreamingCall extends Grpc\BidiStreamingCall
|
||||
{
|
||||
use SerializationTrait;
|
||||
|
||||
private $responses;
|
||||
private $status;
|
||||
private $writesDone = false;
|
||||
private $receivedWrites = [];
|
||||
|
||||
/**
|
||||
* MockBidiStreamingCall constructor.
|
||||
* @param mixed[] $responses A list of response objects.
|
||||
* @param mixed|null $deserialize An optional deserialize method for the response object.
|
||||
* @param stdClass|null $status An optional status object. If set to null, a status of OK is used.
|
||||
*/
|
||||
public function __construct(array $responses, $deserialize = null, ?stdClass $status = null)
|
||||
{
|
||||
$this->responses = $responses;
|
||||
$this->deserialize = $deserialize;
|
||||
if (is_null($status)) {
|
||||
$status = new MockStatus(Code::OK);
|
||||
}
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function read()
|
||||
{
|
||||
if (count($this->responses) > 0) {
|
||||
$resp = array_shift($this->responses);
|
||||
if (is_null($resp)) {
|
||||
// Null was added to the responses list to simulate a failed stream
|
||||
// To ensure that getStatus can now be called, we clear the remaining
|
||||
// responses and set writesDone to true
|
||||
$this->responses = [];
|
||||
$this->writesDone();
|
||||
return null;
|
||||
}
|
||||
$obj = $this->deserializeMessage($resp, $this->deserialize);
|
||||
return $obj;
|
||||
} elseif ($this->writesDone) {
|
||||
return null;
|
||||
} else {
|
||||
throw new ApiException(
|
||||
'No more responses to read, but closeWrite() not called - '
|
||||
. 'this would be blocking',
|
||||
Grpc\STATUS_INTERNAL,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return stdClass|null
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
if (count($this->responses) > 0) {
|
||||
throw new ApiException(
|
||||
'Calls to getStatus() will block if all responses are not read',
|
||||
Grpc\STATUS_INTERNAL,
|
||||
null
|
||||
);
|
||||
}
|
||||
if (!$this->writesDone) {
|
||||
throw new ApiException(
|
||||
'Calls to getStatus() will block if closeWrite() not called',
|
||||
Grpc\STATUS_INTERNAL,
|
||||
null
|
||||
);
|
||||
}
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the request object, to be retrieved via getReceivedCalls()
|
||||
* @param Message|mixed $request The request object
|
||||
* @param array $options An array of options.
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function write($request, array $options = [])
|
||||
{
|
||||
if ($this->writesDone) {
|
||||
throw new ApiException(
|
||||
'Cannot call write() after writesDone()',
|
||||
Grpc\STATUS_INTERNAL,
|
||||
null
|
||||
);
|
||||
}
|
||||
if (is_a($request, '\Google\Protobuf\Internal\Message')) {
|
||||
/** @var Message $newRequest */
|
||||
$newRequest = new $request();
|
||||
$newRequest->mergeFromString($request->serializeToString());
|
||||
$request = $newRequest;
|
||||
}
|
||||
$this->receivedWrites[] = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set writesDone to true
|
||||
*/
|
||||
public function writesDone()
|
||||
{
|
||||
$this->writesDone = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of calls made to write(), and clear $receivedFuncCalls.
|
||||
*
|
||||
* @return mixed[] An array of received requests
|
||||
*/
|
||||
public function popReceivedCalls()
|
||||
{
|
||||
$receivedFuncCallsTemp = $this->receivedWrites;
|
||||
$this->receivedWrites = [];
|
||||
return $receivedFuncCallsTemp;
|
||||
}
|
||||
}
|
||||
111
vendor/google/gax/src/Testing/MockClientStreamingCall.php
vendored
Normal file
111
vendor/google/gax/src/Testing/MockClientStreamingCall.php
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2016 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\ApiCore\ApiException;
|
||||
use Google\ApiCore\ApiStatus;
|
||||
use Google\Protobuf\Internal\Message;
|
||||
use Google\Rpc\Code;
|
||||
use Grpc;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* The MockClientStreamingCall class is used to mock out the \Grpc\ClientStreamingCall class
|
||||
* (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/ClientStreamingCall.php)
|
||||
*
|
||||
* The MockClientStreamingCall object is constructed with a response object, an optional deserialize
|
||||
* method, and an optional status. The response object and status are returned immediately from the
|
||||
* wait() method. It also provides a write() method that accepts request objects, and a
|
||||
* getAllRequests() method that returns all request objects passed to write(), and clears them.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MockClientStreamingCall extends Grpc\ClientStreamingCall
|
||||
{
|
||||
private $mockUnaryCall;
|
||||
private $waitCalled = false;
|
||||
private $receivedWrites = [];
|
||||
|
||||
/**
|
||||
* MockClientStreamingCall constructor.
|
||||
* @param Message|string $response The response object.
|
||||
* @param callable|array|null $deserialize An optional deserialize method for the response object.
|
||||
* @param stdClass|null $status An optional status object. If set to null, a status of OK is used.
|
||||
*/
|
||||
public function __construct($response, $deserialize = null, ?stdClass $status = null)
|
||||
{
|
||||
$this->mockUnaryCall = new MockUnaryCall($response, $deserialize, $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately return the preset response object and status.
|
||||
* @return array The response object and status.
|
||||
*/
|
||||
public function wait()
|
||||
{
|
||||
$this->waitCalled = true;
|
||||
return $this->mockUnaryCall->wait();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the request object, to be retrieved via getReceivedCalls()
|
||||
* @param Message|mixed $request The request object
|
||||
* @param array $options An array of options
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function write($request, array $options = [])
|
||||
{
|
||||
if ($this->waitCalled) {
|
||||
throw new ApiException('Cannot call write() after wait()', Code::INTERNAL, ApiStatus::INTERNAL);
|
||||
}
|
||||
if (is_a($request, '\Google\Protobuf\Internal\Message')) {
|
||||
/** @var Message $newRequest */
|
||||
$newRequest = new $request();
|
||||
$newRequest->mergeFromString($request->serializeToString());
|
||||
$request = $newRequest;
|
||||
}
|
||||
$this->receivedWrites[] = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of calls made to write(), and clear $receivedFuncCalls.
|
||||
*
|
||||
* @return mixed[] An array of received requests
|
||||
*/
|
||||
public function popReceivedCalls()
|
||||
{
|
||||
$receivedFuncCallsTemp = $this->receivedWrites;
|
||||
$this->receivedWrites = [];
|
||||
return $receivedFuncCallsTemp;
|
||||
}
|
||||
}
|
||||
142
vendor/google/gax/src/Testing/MockGrpcTransport.php
vendored
Normal file
142
vendor/google/gax/src/Testing/MockGrpcTransport.php
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2018 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\ApiCore\Transport\GrpcTransport;
|
||||
use Grpc\ChannelCredentials;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class MockGrpcTransport extends GrpcTransport
|
||||
{
|
||||
private $requestArguments;
|
||||
private $mockCall;
|
||||
|
||||
/**
|
||||
* @param mixed $mockCall
|
||||
*/
|
||||
public function __construct($mockCall = null, ?LoggerInterface $logger = null)
|
||||
{
|
||||
$this->mockCall = $mockCall;
|
||||
$opts = ['credentials' => ChannelCredentials::createSsl()];
|
||||
parent::__construct('', $opts, logger: $logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param array $arguments
|
||||
* @param callable $deserialize
|
||||
*/
|
||||
protected function _simpleRequest(
|
||||
$method,
|
||||
$arguments,
|
||||
$deserialize,
|
||||
array $metadata = [],
|
||||
array $options = []
|
||||
) {
|
||||
$this->logCall($method, $deserialize, $metadata, $options, $arguments);
|
||||
return $this->mockCall;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param callable $deserialize
|
||||
*/
|
||||
protected function _clientStreamRequest(
|
||||
$method,
|
||||
$deserialize,
|
||||
array $metadata = [],
|
||||
array $options = []
|
||||
) {
|
||||
$this->logCall($method, $deserialize, $metadata, $options);
|
||||
return $this->mockCall;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param array $arguments
|
||||
* @param callable $deserialize
|
||||
*/
|
||||
protected function _serverStreamRequest(
|
||||
$method,
|
||||
$arguments,
|
||||
$deserialize,
|
||||
array $metadata = [],
|
||||
array $options = []
|
||||
) {
|
||||
$this->logCall($method, $deserialize, $metadata, $options, $arguments);
|
||||
return $this->mockCall;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param callable $deserialize
|
||||
*/
|
||||
protected function _bidiRequest(
|
||||
$method,
|
||||
$deserialize,
|
||||
array $metadata = [],
|
||||
array $options = []
|
||||
) {
|
||||
$this->logCall($method, $deserialize, $metadata, $options);
|
||||
return $this->mockCall;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param callable $deserialize
|
||||
* @param array $arguments
|
||||
*/
|
||||
private function logCall(
|
||||
$method,
|
||||
$deserialize,
|
||||
array $metadata = [],
|
||||
array $options = [],
|
||||
$arguments = null
|
||||
) {
|
||||
$this->requestArguments = [
|
||||
'method' => $method,
|
||||
'arguments' => $arguments,
|
||||
'deserialize' => $deserialize,
|
||||
'metadata' => $metadata,
|
||||
'options' => $options,
|
||||
];
|
||||
}
|
||||
|
||||
public function getRequestArguments()
|
||||
{
|
||||
return $this->requestArguments;
|
||||
}
|
||||
}
|
||||
86
vendor/google/gax/src/Testing/MockRequest.php
vendored
Normal file
86
vendor/google/gax/src/Testing/MockRequest.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: Testing/mocks.proto
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
use GPBMetadata\ApiCore\Testing\Mocks;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>google.apicore.testing.MockRequest</code>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MockRequest extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Generated from protobuf field <code>string page_token = 1;</code>
|
||||
*/
|
||||
protected $page_token = '';
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 page_size = 2;</code>
|
||||
*/
|
||||
protected $page_size = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type string $page_token
|
||||
* @type int|string $page_size
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = null)
|
||||
{
|
||||
Mocks::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string page_token = 1;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getPageToken()
|
||||
{
|
||||
return $this->page_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string page_token = 1;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setPageToken($var)
|
||||
{
|
||||
GPBUtil::checkString($var, true);
|
||||
$this->page_token = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 page_size = 2;</code>
|
||||
* @return int|string
|
||||
*/
|
||||
public function getPageSize()
|
||||
{
|
||||
return $this->page_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 page_size = 2;</code>
|
||||
* @param int|string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setPageSize($var)
|
||||
{
|
||||
GPBUtil::checkUint64($var);
|
||||
$this->page_size = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
647
vendor/google/gax/src/Testing/MockRequestBody.php
vendored
Normal file
647
vendor/google/gax/src/Testing/MockRequestBody.php
vendored
Normal file
@@ -0,0 +1,647 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: Testing/mocks.proto
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>google.apicore.testing.MockRequestBody</code>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MockRequestBody extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Generated from protobuf field <code>string name = 1;</code>
|
||||
*/
|
||||
protected $name = '';
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 number = 2;</code>
|
||||
*/
|
||||
protected $number = 0;
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated string repeated_field = 3;</code>
|
||||
*/
|
||||
private $repeated_field;
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.apicore.testing.MockRequestBody nested_message = 4;</code>
|
||||
*/
|
||||
protected $nested_message = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.BytesValue bytes_value = 5;</code>
|
||||
*/
|
||||
protected $bytes_value = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Duration duration_value = 6;</code>
|
||||
*/
|
||||
protected $duration_value = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.FieldMask field_mask = 7;</code>
|
||||
*/
|
||||
protected $field_mask = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Int64Value int64_value = 8;</code>
|
||||
*/
|
||||
protected $int64_value = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.ListValue list_value = 9;</code>
|
||||
*/
|
||||
protected $list_value = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.StringValue string_value = 10;</code>
|
||||
*/
|
||||
protected $string_value = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Struct struct_value = 11;</code>
|
||||
*/
|
||||
protected $struct_value = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Timestamp timestamp_value = 12;</code>
|
||||
*/
|
||||
protected $timestamp_value = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Value value_value = 13;</code>
|
||||
*/
|
||||
protected $value_value = null;
|
||||
protected $oneof_field;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type string $name
|
||||
* @type int|string $number
|
||||
* @type string[]|\Google\Protobuf\RepeatedField $repeated_field
|
||||
* @type \Google\ApiCore\Testing\MockRequestBody $nested_message
|
||||
* @type \Google\Protobuf\BytesValue $bytes_value
|
||||
* @type \Google\Protobuf\Duration $duration_value
|
||||
* @type \Google\Protobuf\FieldMask $field_mask
|
||||
* @type \Google\Protobuf\Int64Value $int64_value
|
||||
* @type \Google\Protobuf\ListValue $list_value
|
||||
* @type \Google\Protobuf\StringValue $string_value
|
||||
* @type \Google\Protobuf\Struct $struct_value
|
||||
* @type \Google\Protobuf\Timestamp $timestamp_value
|
||||
* @type \Google\Protobuf\Value $value_value
|
||||
* @type string $field_1
|
||||
* @type string $field_2
|
||||
* @type string $field_3
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = null)
|
||||
{
|
||||
\GPBMetadata\ApiCore\Testing\Mocks::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string name = 1;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string name = 1;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($var)
|
||||
{
|
||||
GPBUtil::checkString($var, true);
|
||||
$this->name = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 number = 2;</code>
|
||||
* @return int|string
|
||||
*/
|
||||
public function getNumber()
|
||||
{
|
||||
return $this->number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 number = 2;</code>
|
||||
* @param int|string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setNumber($var)
|
||||
{
|
||||
GPBUtil::checkUint64($var);
|
||||
$this->number = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated string repeated_field = 3;</code>
|
||||
* @return \Google\Protobuf\RepeatedField
|
||||
*/
|
||||
public function getRepeatedField()
|
||||
{
|
||||
return $this->repeated_field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated string repeated_field = 3;</code>
|
||||
* @param string[]|\Google\Protobuf\RepeatedField $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setRepeatedField($var)
|
||||
{
|
||||
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
|
||||
$this->repeated_field = $arr;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.apicore.testing.MockRequestBody nested_message = 4;</code>
|
||||
* @return \Google\ApiCore\Testing\MockRequestBody
|
||||
*/
|
||||
public function getNestedMessage()
|
||||
{
|
||||
return isset($this->nested_message) ? $this->nested_message : null;
|
||||
}
|
||||
|
||||
public function hasNestedMessage()
|
||||
{
|
||||
return isset($this->nested_message);
|
||||
}
|
||||
|
||||
public function clearNestedMessage()
|
||||
{
|
||||
unset($this->nested_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.apicore.testing.MockRequestBody nested_message = 4;</code>
|
||||
* @param \Google\ApiCore\Testing\MockRequestBody $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setNestedMessage($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Google\ApiCore\Testing\MockRequestBody::class);
|
||||
$this->nested_message = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.BytesValue bytes_value = 5;</code>
|
||||
* @return \Google\Protobuf\BytesValue
|
||||
*/
|
||||
public function getBytesValue()
|
||||
{
|
||||
return isset($this->bytes_value) ? $this->bytes_value : null;
|
||||
}
|
||||
|
||||
public function hasBytesValue()
|
||||
{
|
||||
return isset($this->bytes_value);
|
||||
}
|
||||
|
||||
public function clearBytesValue()
|
||||
{
|
||||
unset($this->bytes_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unboxed value from <code>getBytesValue()</code>
|
||||
|
||||
* Generated from protobuf field <code>.google.protobuf.BytesValue bytes_value = 5;</code>
|
||||
* @return string|null
|
||||
*/
|
||||
public function getBytesValueUnwrapped()
|
||||
{
|
||||
return $this->readWrapperValue('bytes_value');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.BytesValue bytes_value = 5;</code>
|
||||
* @param \Google\Protobuf\BytesValue $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setBytesValue($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Google\Protobuf\BytesValue::class);
|
||||
$this->bytes_value = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field by wrapping a primitive type in a Google\Protobuf\BytesValue object.
|
||||
|
||||
* Generated from protobuf field <code>.google.protobuf.BytesValue bytes_value = 5;</code>
|
||||
* @param string|null $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setBytesValueUnwrapped($var)
|
||||
{
|
||||
$this->writeWrapperValue('bytes_value', $var);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Duration duration_value = 6;</code>
|
||||
* @return \Google\Protobuf\Duration
|
||||
*/
|
||||
public function getDurationValue()
|
||||
{
|
||||
return isset($this->duration_value) ? $this->duration_value : null;
|
||||
}
|
||||
|
||||
public function hasDurationValue()
|
||||
{
|
||||
return isset($this->duration_value);
|
||||
}
|
||||
|
||||
public function clearDurationValue()
|
||||
{
|
||||
unset($this->duration_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Duration duration_value = 6;</code>
|
||||
* @param \Google\Protobuf\Duration $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setDurationValue($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class);
|
||||
$this->duration_value = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.FieldMask field_mask = 7;</code>
|
||||
* @return \Google\Protobuf\FieldMask
|
||||
*/
|
||||
public function getFieldMask()
|
||||
{
|
||||
return isset($this->field_mask) ? $this->field_mask : null;
|
||||
}
|
||||
|
||||
public function hasFieldMask()
|
||||
{
|
||||
return isset($this->field_mask);
|
||||
}
|
||||
|
||||
public function clearFieldMask()
|
||||
{
|
||||
unset($this->field_mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.FieldMask field_mask = 7;</code>
|
||||
* @param \Google\Protobuf\FieldMask $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setFieldMask($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class);
|
||||
$this->field_mask = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Int64Value int64_value = 8;</code>
|
||||
* @return \Google\Protobuf\Int64Value
|
||||
*/
|
||||
public function getInt64Value()
|
||||
{
|
||||
return isset($this->int64_value) ? $this->int64_value : null;
|
||||
}
|
||||
|
||||
public function hasInt64Value()
|
||||
{
|
||||
return isset($this->int64_value);
|
||||
}
|
||||
|
||||
public function clearInt64Value()
|
||||
{
|
||||
unset($this->int64_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unboxed value from <code>getInt64Value()</code>
|
||||
|
||||
* Generated from protobuf field <code>.google.protobuf.Int64Value int64_value = 8;</code>
|
||||
* @return int|string|null
|
||||
*/
|
||||
public function getInt64ValueUnwrapped()
|
||||
{
|
||||
return $this->readWrapperValue('int64_value');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Int64Value int64_value = 8;</code>
|
||||
* @param \Google\Protobuf\Int64Value $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setInt64Value($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Google\Protobuf\Int64Value::class);
|
||||
$this->int64_value = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field by wrapping a primitive type in a Google\Protobuf\Int64Value object.
|
||||
|
||||
* Generated from protobuf field <code>.google.protobuf.Int64Value int64_value = 8;</code>
|
||||
* @param int|string|null $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setInt64ValueUnwrapped($var)
|
||||
{
|
||||
$this->writeWrapperValue('int64_value', $var);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.ListValue list_value = 9;</code>
|
||||
* @return \Google\Protobuf\ListValue
|
||||
*/
|
||||
public function getListValue()
|
||||
{
|
||||
return isset($this->list_value) ? $this->list_value : null;
|
||||
}
|
||||
|
||||
public function hasListValue()
|
||||
{
|
||||
return isset($this->list_value);
|
||||
}
|
||||
|
||||
public function clearListValue()
|
||||
{
|
||||
unset($this->list_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.ListValue list_value = 9;</code>
|
||||
* @param \Google\Protobuf\ListValue $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setListValue($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Google\Protobuf\ListValue::class);
|
||||
$this->list_value = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.StringValue string_value = 10;</code>
|
||||
* @return \Google\Protobuf\StringValue
|
||||
*/
|
||||
public function getStringValue()
|
||||
{
|
||||
return isset($this->string_value) ? $this->string_value : null;
|
||||
}
|
||||
|
||||
public function hasStringValue()
|
||||
{
|
||||
return isset($this->string_value);
|
||||
}
|
||||
|
||||
public function clearStringValue()
|
||||
{
|
||||
unset($this->string_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unboxed value from <code>getStringValue()</code>
|
||||
|
||||
* Generated from protobuf field <code>.google.protobuf.StringValue string_value = 10;</code>
|
||||
* @return string|null
|
||||
*/
|
||||
public function getStringValueUnwrapped()
|
||||
{
|
||||
return $this->readWrapperValue('string_value');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.StringValue string_value = 10;</code>
|
||||
* @param \Google\Protobuf\StringValue $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setStringValue($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Google\Protobuf\StringValue::class);
|
||||
$this->string_value = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field by wrapping a primitive type in a Google\Protobuf\StringValue object.
|
||||
|
||||
* Generated from protobuf field <code>.google.protobuf.StringValue string_value = 10;</code>
|
||||
* @param string|null $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setStringValueUnwrapped($var)
|
||||
{
|
||||
$this->writeWrapperValue('string_value', $var);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Struct struct_value = 11;</code>
|
||||
* @return \Google\Protobuf\Struct
|
||||
*/
|
||||
public function getStructValue()
|
||||
{
|
||||
return isset($this->struct_value) ? $this->struct_value : null;
|
||||
}
|
||||
|
||||
public function hasStructValue()
|
||||
{
|
||||
return isset($this->struct_value);
|
||||
}
|
||||
|
||||
public function clearStructValue()
|
||||
{
|
||||
unset($this->struct_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Struct struct_value = 11;</code>
|
||||
* @param \Google\Protobuf\Struct $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setStructValue($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class);
|
||||
$this->struct_value = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Timestamp timestamp_value = 12;</code>
|
||||
* @return \Google\Protobuf\Timestamp
|
||||
*/
|
||||
public function getTimestampValue()
|
||||
{
|
||||
return isset($this->timestamp_value) ? $this->timestamp_value : null;
|
||||
}
|
||||
|
||||
public function hasTimestampValue()
|
||||
{
|
||||
return isset($this->timestamp_value);
|
||||
}
|
||||
|
||||
public function clearTimestampValue()
|
||||
{
|
||||
unset($this->timestamp_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Timestamp timestamp_value = 12;</code>
|
||||
* @param \Google\Protobuf\Timestamp $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimestampValue($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
|
||||
$this->timestamp_value = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Value value_value = 13;</code>
|
||||
* @return \Google\Protobuf\Value
|
||||
*/
|
||||
public function getValueValue()
|
||||
{
|
||||
return isset($this->value_value) ? $this->value_value : null;
|
||||
}
|
||||
|
||||
public function hasValueValue()
|
||||
{
|
||||
return isset($this->value_value);
|
||||
}
|
||||
|
||||
public function clearValueValue()
|
||||
{
|
||||
unset($this->value_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.google.protobuf.Value value_value = 13;</code>
|
||||
* @param \Google\Protobuf\Value $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setValueValue($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Google\Protobuf\Value::class);
|
||||
$this->value_value = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string field_1 = 14;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getField1()
|
||||
{
|
||||
return $this->readOneof(14);
|
||||
}
|
||||
|
||||
public function hasField1()
|
||||
{
|
||||
return $this->hasOneof(14);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string field_1 = 14;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setField1($var)
|
||||
{
|
||||
GPBUtil::checkString($var, true);
|
||||
$this->writeOneof(14, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string field_2 = 15;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getField2()
|
||||
{
|
||||
return $this->readOneof(15);
|
||||
}
|
||||
|
||||
public function hasField2()
|
||||
{
|
||||
return $this->hasOneof(15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string field_2 = 15;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setField2($var)
|
||||
{
|
||||
GPBUtil::checkString($var, true);
|
||||
$this->writeOneof(15, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string field_3 = 16;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getField3()
|
||||
{
|
||||
return $this->readOneof(16);
|
||||
}
|
||||
|
||||
public function hasField3()
|
||||
{
|
||||
return $this->hasOneof(16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string field_3 = 16;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setField3($var)
|
||||
{
|
||||
GPBUtil::checkString($var, true);
|
||||
$this->writeOneof(16, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOneofField()
|
||||
{
|
||||
return $this->whichOneof('oneof_field');
|
||||
}
|
||||
|
||||
}
|
||||
166
vendor/google/gax/src/Testing/MockResponse.php
vendored
Normal file
166
vendor/google/gax/src/Testing/MockResponse.php
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: Testing/mocks.proto
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>google.apicore.testing.MockResponse</code>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MockResponse extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Generated from protobuf field <code>string name = 1;</code>
|
||||
*/
|
||||
protected $name = '';
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 number = 2;</code>
|
||||
*/
|
||||
protected $number = 0;
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated string resources_list = 3;</code>
|
||||
*/
|
||||
private $resources_list;
|
||||
/**
|
||||
* Generated from protobuf field <code>string next_page_token = 4;</code>
|
||||
*/
|
||||
protected $next_page_token = '';
|
||||
/**
|
||||
* Generated from protobuf field <code>map<string, string> resources_map = 5;</code>
|
||||
*/
|
||||
private $resources_map;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type string $name
|
||||
* @type int|string $number
|
||||
* @type string[]|\Google\Protobuf\RepeatedField $resources_list
|
||||
* @type string $next_page_token
|
||||
* @type array|\Google\Protobuf\Internal\MapField $resources_map
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = null)
|
||||
{
|
||||
\GPBMetadata\ApiCore\Testing\Mocks::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string name = 1;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string name = 1;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($var)
|
||||
{
|
||||
GPBUtil::checkString($var, true);
|
||||
$this->name = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 number = 2;</code>
|
||||
* @return int|string
|
||||
*/
|
||||
public function getNumber()
|
||||
{
|
||||
return $this->number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 number = 2;</code>
|
||||
* @param int|string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setNumber($var)
|
||||
{
|
||||
GPBUtil::checkUint64($var);
|
||||
$this->number = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated string resources_list = 3;</code>
|
||||
* @return \Google\Protobuf\RepeatedField
|
||||
*/
|
||||
public function getResourcesList()
|
||||
{
|
||||
return $this->resources_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated string resources_list = 3;</code>
|
||||
* @param string[]|\Google\Protobuf\RepeatedField $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setResourcesList($var)
|
||||
{
|
||||
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
|
||||
$this->resources_list = $arr;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string next_page_token = 4;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getNextPageToken()
|
||||
{
|
||||
return $this->next_page_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string next_page_token = 4;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setNextPageToken($var)
|
||||
{
|
||||
GPBUtil::checkString($var, true);
|
||||
$this->next_page_token = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>map<string, string> resources_map = 5;</code>
|
||||
* @return \Google\Protobuf\Internal\MapField
|
||||
*/
|
||||
public function getResourcesMap()
|
||||
{
|
||||
return $this->resources_map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>map<string, string> resources_map = 5;</code>
|
||||
* @param array|\Google\Protobuf\Internal\MapField $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setResourcesMap($var)
|
||||
{
|
||||
$arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING);
|
||||
$this->resources_map = $arr;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
98
vendor/google/gax/src/Testing/MockServerStreamingCall.php
vendored
Normal file
98
vendor/google/gax/src/Testing/MockServerStreamingCall.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2016 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\ApiCore\ApiException;
|
||||
use Google\ApiCore\ApiStatus;
|
||||
use Google\ApiCore\ServerStreamingCallInterface;
|
||||
use Google\Rpc\Code;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* The MockServerStreamingCall class is used to mock out the \Grpc\ServerStreamingCall class
|
||||
* (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/ServerStreamingCall.php)
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MockServerStreamingCall extends \Grpc\ServerStreamingCall implements ServerStreamingCallInterface
|
||||
{
|
||||
use SerializationTrait;
|
||||
|
||||
private $responses;
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* MockServerStreamingCall constructor.
|
||||
* @param mixed[] $responses A list of response objects.
|
||||
* @param callable|array|null $deserialize An optional deserialize method for the response object.
|
||||
* @param stdClass|null $status An optional status object. If set to null, a status of OK is used.
|
||||
*/
|
||||
public function __construct(array $responses, $deserialize = null, ?stdClass $status = null)
|
||||
{
|
||||
$this->responses = $responses;
|
||||
$this->deserialize = $deserialize;
|
||||
if (is_null($status)) {
|
||||
$status = new MockStatus(Code::OK, 'OK', []);
|
||||
} elseif ($status instanceof stdClass) {
|
||||
if (!property_exists($status, 'metadata')) {
|
||||
$status->metadata = [];
|
||||
}
|
||||
}
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function responses()
|
||||
{
|
||||
while (count($this->responses) > 0) {
|
||||
$resp = array_shift($this->responses);
|
||||
$obj = $this->deserializeMessage($resp, $this->deserialize);
|
||||
yield $obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return stdClass|null
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
if (count($this->responses) > 0) {
|
||||
throw new ApiException(
|
||||
'Calls to getStatus() will block if all responses are not read',
|
||||
Code::INTERNAL,
|
||||
ApiStatus::INTERNAL
|
||||
);
|
||||
}
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
53
vendor/google/gax/src/Testing/MockStatus.php
vendored
Normal file
53
vendor/google/gax/src/Testing/MockStatus.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2016 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\Rpc\Code;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class MockStatus extends stdClass
|
||||
{
|
||||
/** @var Code|int $code */
|
||||
public $code;
|
||||
public $details;
|
||||
public $metadata;
|
||||
public function __construct($code, ?string $details = null, array $metadata = [])
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->details = $details;
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
}
|
||||
296
vendor/google/gax/src/Testing/MockStubTrait.php
vendored
Normal file
296
vendor/google/gax/src/Testing/MockStubTrait.php
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2016 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\Protobuf\Internal\Message;
|
||||
use stdClass;
|
||||
use UnderflowException;
|
||||
|
||||
/**
|
||||
* The MockStubTrait is used by generated mock stub classes which extent \Grpc\BaseStub
|
||||
* (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php)
|
||||
* It provides functionality to add responses, get received calls, and overrides the _simpleRequest
|
||||
* method so that the elements of $responses are returned instead of making a call to the API.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
trait MockStubTrait
|
||||
{
|
||||
private $receivedFuncCalls = [];
|
||||
private $responses = [];
|
||||
private $serverStreamingStatus = null;
|
||||
private $callObjects = [];
|
||||
private $deserialize;
|
||||
|
||||
public function __construct(?callable $deserialize = null)
|
||||
{
|
||||
$this->deserialize = $deserialize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the _simpleRequest method in \Grpc\BaseStub
|
||||
* (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php)
|
||||
* Returns a MockUnaryCall object that will return the first item from $responses
|
||||
* @param string $method The API method name to be called
|
||||
* @param \Google\Protobuf\Internal\Message $argument The request object to the API method
|
||||
* @param callable $deserialize A function to deserialize the response object
|
||||
* @param array $metadata
|
||||
* @param array $options
|
||||
* @return MockUnaryCall
|
||||
*/
|
||||
public function _simpleRequest(
|
||||
$method,
|
||||
$argument,
|
||||
$deserialize,
|
||||
array $metadata = [],
|
||||
array $options = []
|
||||
) {
|
||||
$this->receivedFuncCalls[] = new ReceivedRequest($method, $argument, $deserialize, $metadata, $options);
|
||||
if (count($this->responses) < 1) {
|
||||
throw new UnderflowException('ran out of responses');
|
||||
}
|
||||
list($response, $status) = array_shift($this->responses);
|
||||
$call = new MockUnaryCall($response, $deserialize, $status);
|
||||
$this->callObjects[] = $call;
|
||||
return $call;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the _clientStreamRequest method in \Grpc\BaseStub
|
||||
* (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php)
|
||||
* Returns a MockClientStreamingCall object that will return the first item from $responses
|
||||
*
|
||||
* @param string $method The name of the method to call
|
||||
* @param callable $deserialize A function that deserializes the responses
|
||||
* @param array $metadata A metadata map to send to the server
|
||||
* (optional)
|
||||
* @param array $options An array of options (optional)
|
||||
*
|
||||
* @return MockClientStreamingCall The active call object
|
||||
*/
|
||||
public function _clientStreamRequest(
|
||||
$method,
|
||||
$deserialize,
|
||||
array $metadata = [],
|
||||
array $options = []
|
||||
) {
|
||||
$this->receivedFuncCalls[] = new ReceivedRequest($method, null, $deserialize, $metadata, $options);
|
||||
if (count($this->responses) < 1) {
|
||||
throw new UnderflowException('ran out of responses');
|
||||
}
|
||||
list($response, $status) = array_shift($this->responses);
|
||||
$call = new MockClientStreamingCall($response, $deserialize, $status);
|
||||
$this->callObjects[] = $call;
|
||||
return $call;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the _serverStreamRequest method in \Grpc\BaseStub
|
||||
* (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php)
|
||||
* Returns a MockServerStreamingCall object that will stream items from $responses, and return
|
||||
* a final status of $serverStreamingStatus.
|
||||
*
|
||||
* @param string $method The name of the method to call
|
||||
* @param \Google\Protobuf\Internal\Message $argument The argument to the method
|
||||
* @param callable $deserialize A function that deserializes the responses
|
||||
* @param array $metadata A metadata map to send to the server
|
||||
* (optional)
|
||||
* @param array $options An array of options (optional)
|
||||
*
|
||||
* @return MockServerStreamingCall The active call object
|
||||
*/
|
||||
public function _serverStreamRequest(
|
||||
$method,
|
||||
$argument,
|
||||
$deserialize,
|
||||
array $metadata = [],
|
||||
array $options = []
|
||||
) {
|
||||
|
||||
if (is_a($argument, '\Google\Protobuf\Internal\Message')) {
|
||||
/** @var Message $newArgument */
|
||||
$newArgument = new $argument();
|
||||
$newArgument->mergeFromString($argument->serializeToString());
|
||||
$argument = $newArgument;
|
||||
}
|
||||
$this->receivedFuncCalls[] = new ReceivedRequest($method, $argument, $deserialize, $metadata, $options);
|
||||
$responses = self::stripStatusFromResponses($this->responses);
|
||||
$this->responses = [];
|
||||
$call = new MockServerStreamingCall($responses, $deserialize, $this->serverStreamingStatus);
|
||||
$this->callObjects[] = $call;
|
||||
return $call;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the _bidiRequest method in \Grpc\BaseStub
|
||||
* (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php)
|
||||
* Returns a MockBidiStreamingCall object that will stream items from $responses, and return
|
||||
* a final status of $serverStreamingStatus.
|
||||
*
|
||||
* @param string $method The name of the method to call
|
||||
* @param callable $deserialize A function that deserializes the responses
|
||||
* @param array $metadata A metadata map to send to the server
|
||||
* (optional)
|
||||
* @param array $options An array of options (optional)
|
||||
*
|
||||
* @return MockBidiStreamingCall The active call object
|
||||
*/
|
||||
public function _bidiRequest(
|
||||
$method,
|
||||
$deserialize,
|
||||
array $metadata = [],
|
||||
array $options = []
|
||||
) {
|
||||
|
||||
$this->receivedFuncCalls[] = new ReceivedRequest($method, null, $deserialize, $metadata, $options);
|
||||
$responses = self::stripStatusFromResponses($this->responses);
|
||||
$this->responses = [];
|
||||
$call = new MockBidiStreamingCall($responses, $deserialize, $this->serverStreamingStatus);
|
||||
$this->callObjects[] = $call;
|
||||
return $call;
|
||||
}
|
||||
|
||||
public static function stripStatusFromResponses($responses)
|
||||
{
|
||||
$strippedResponses = [];
|
||||
foreach ($responses as $response) {
|
||||
list($resp, $_) = $response;
|
||||
$strippedResponses[] = $resp;
|
||||
}
|
||||
return $strippedResponses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a response object, and an optional status, to the list of responses to be returned via
|
||||
* _simpleRequest.
|
||||
* @param \Google\Protobuf\Internal\Message $response
|
||||
* @param stdClass $status
|
||||
*/
|
||||
public function addResponse($response, ?stdClass $status = null)
|
||||
{
|
||||
if (!$this->deserialize && $response) {
|
||||
$this->deserialize = [get_class($response), 'decode'];
|
||||
}
|
||||
|
||||
if (is_a($response, '\Google\Protobuf\Internal\Message')) {
|
||||
$response = $response->serializeToString();
|
||||
}
|
||||
$this->responses[] = [$response, $status];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the status object to be used when creating streaming calls.
|
||||
*
|
||||
* @param stdClass $status
|
||||
*/
|
||||
public function setStreamingStatus(stdClass $status)
|
||||
{
|
||||
$this->serverStreamingStatus = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of calls made to _simpleRequest, and clear $receivedFuncCalls.
|
||||
*
|
||||
* @return ReceivedRequest[] An array of received requests
|
||||
*/
|
||||
public function popReceivedCalls()
|
||||
{
|
||||
$receivedFuncCallsTemp = $this->receivedFuncCalls;
|
||||
$this->receivedFuncCalls = [];
|
||||
return $receivedFuncCallsTemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int The number of calls received.
|
||||
*/
|
||||
public function getReceivedCallCount()
|
||||
{
|
||||
return count($this->receivedFuncCalls);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[] The call objects created by calls to the stub
|
||||
*/
|
||||
public function popCallObjects()
|
||||
{
|
||||
$callObjectsTemp = $this->callObjects;
|
||||
$this->callObjects = [];
|
||||
return $callObjectsTemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool True if $receivedFuncCalls and $response are empty.
|
||||
*/
|
||||
public function isExhausted()
|
||||
{
|
||||
return count($this->receivedFuncCalls) === 0
|
||||
&& count($this->responses) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $responseObject
|
||||
* @param stdClass|null $status
|
||||
* @param callable $deserialize
|
||||
* @return static An instance of the current class type.
|
||||
*/
|
||||
public static function create($responseObject, ?stdClass $status = null, ?callable $deserialize = null)
|
||||
{
|
||||
$stub = new static($deserialize); // @phpstan-ignore-line
|
||||
$stub->addResponse($responseObject, $status);
|
||||
return $stub;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a sequence such that the responses are returned in order.
|
||||
* @param mixed[] $sequence
|
||||
* @param callable $deserialize
|
||||
* @param stdClass $finalStatus
|
||||
* @return static An instance of the current class type.
|
||||
*/
|
||||
public static function createWithResponseSequence(array $sequence, ?callable $deserialize = null, ?stdClass $finalStatus = null)
|
||||
{
|
||||
$stub = new static($deserialize); // @phpstan-ignore-line
|
||||
foreach ($sequence as $elem) {
|
||||
if (count($elem) == 1) {
|
||||
list($resp, $status) = [$elem, null];
|
||||
} else {
|
||||
list($resp, $status) = $elem;
|
||||
}
|
||||
$stub->addResponse($resp, $status);
|
||||
}
|
||||
if ($finalStatus) {
|
||||
$stub->setStreamingStatus($finalStatus);
|
||||
}
|
||||
return $stub;
|
||||
}
|
||||
}
|
||||
114
vendor/google/gax/src/Testing/MockTransport.php
vendored
Normal file
114
vendor/google/gax/src/Testing/MockTransport.php
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2018 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\ApiCore\ApiException;
|
||||
use Google\ApiCore\BidiStream;
|
||||
use Google\ApiCore\Call;
|
||||
use Google\ApiCore\ClientStream;
|
||||
use Google\ApiCore\ServerStream;
|
||||
use Google\ApiCore\Transport\TransportInterface;
|
||||
use Google\Rpc\Code;
|
||||
use GuzzleHttp\Promise\Promise;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class MockTransport implements TransportInterface
|
||||
{
|
||||
use MockStubTrait;
|
||||
|
||||
private $agentHeaderDescriptor; // @phpstan-ignore-line
|
||||
|
||||
public function setAgentHeaderDescriptor($agentHeaderDescriptor)
|
||||
{
|
||||
$this->agentHeaderDescriptor = $agentHeaderDescriptor;
|
||||
}
|
||||
|
||||
public function startUnaryCall(Call $call, array $options)
|
||||
{
|
||||
$call = call_user_func([$this, $call->getMethod()], $call, $options);
|
||||
return $promise = new Promise(
|
||||
function () use ($call, &$promise) {
|
||||
list($response, $status) = $call->wait();
|
||||
|
||||
if ($status->code == Code::OK) {
|
||||
$promise->resolve($response);
|
||||
} else {
|
||||
throw ApiException::createFromStdClass($status);
|
||||
}
|
||||
},
|
||||
[$call, 'cancel']
|
||||
);
|
||||
}
|
||||
|
||||
public function startBidiStreamingCall(Call $call, array $options)
|
||||
{
|
||||
$newArgs = ['/' . $call->getMethod(), $this->deserialize, $options, $options];
|
||||
$response = $this->_bidiRequest(...$newArgs);
|
||||
return new BidiStream($response, $call->getDescriptor());
|
||||
}
|
||||
|
||||
public function startClientStreamingCall(Call $call, array $options)
|
||||
{
|
||||
$newArgs = ['/' . $call->getMethod(), $this->deserialize, $options, $options];
|
||||
$response = $this->_clientStreamRequest(...$newArgs);
|
||||
return new ClientStream($response, $call->getDescriptor());
|
||||
}
|
||||
|
||||
public function startServerStreamingCall(Call $call, array $options)
|
||||
{
|
||||
$newArgs = ['/' . $call->getMethod(), $call->getMessage(), $this->deserialize, $options, $options];
|
||||
$response = $this->_serverStreamRequest(...$newArgs);
|
||||
return new ServerStream($response, $call->getDescriptor());
|
||||
}
|
||||
|
||||
public function __call(string $name, array $arguments)
|
||||
{
|
||||
$call = $arguments[0];
|
||||
$options = $arguments[1];
|
||||
$decode = $call->getDecodeType() ? [$call->getDecodeType(), 'decode'] : null;
|
||||
return $this->_simpleRequest(
|
||||
'/' . $call->getMethod(),
|
||||
$call->getMessage(),
|
||||
$decode,
|
||||
isset($options['headers']) ? $options['headers'] : [],
|
||||
$options
|
||||
);
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
// does nothing
|
||||
}
|
||||
}
|
||||
83
vendor/google/gax/src/Testing/MockUnaryCall.php
vendored
Normal file
83
vendor/google/gax/src/Testing/MockUnaryCall.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2016 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\Protobuf\Internal\Message;
|
||||
use Google\Rpc\Code;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* The MockUnaryCall class is used to mock out the \Grpc\UnaryCall class
|
||||
* (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/UnaryCall.php)
|
||||
*
|
||||
* The MockUnaryCall object is constructed with a response object, an optional deserialize
|
||||
* method, and an optional status. The response object and status are returned immediately from the
|
||||
* wait() method.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MockUnaryCall extends \Grpc\UnaryCall
|
||||
{
|
||||
use SerializationTrait;
|
||||
|
||||
private $response;
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* MockUnaryCall constructor.
|
||||
* @param Message|string|null $response The response object.
|
||||
* @param callable|array|null $deserialize An optional deserialize method for the response object.
|
||||
* @param stdClass|null $status An optional status object. If set to null, a status of OK is used.
|
||||
*/
|
||||
public function __construct($response = null, $deserialize = null, ?stdClass $status = null)
|
||||
{
|
||||
$this->response = $response;
|
||||
$this->deserialize = $deserialize;
|
||||
if (is_null($status)) {
|
||||
$status = new MockStatus(Code::OK);
|
||||
}
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately return the preset response object and status.
|
||||
* @return array The response object and status.
|
||||
*/
|
||||
public function wait()
|
||||
{
|
||||
return [
|
||||
$this->deserializeMessage($this->response, $this->deserialize),
|
||||
$this->status,
|
||||
];
|
||||
}
|
||||
}
|
||||
61
vendor/google/gax/src/Testing/ProtobufGPBEmptyComparator.php
vendored
Normal file
61
vendor/google/gax/src/Testing/ProtobufGPBEmptyComparator.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\Protobuf\GPBEmpty;
|
||||
use Google\Protobuf\Internal\Message;
|
||||
use SebastianBergmann\Comparator\Comparator;
|
||||
use SebastianBergmann\Comparator\ComparisonFailure;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ProtobufGPBEmptyComparator extends Comparator
|
||||
{
|
||||
/**
|
||||
* Returns whether the comparator can compare two values.
|
||||
*
|
||||
* @param mixed $expected The first value to compare
|
||||
* @param mixed $actual The second value to compare
|
||||
* @return boolean
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return $expected instanceof GPBEmpty && $actual instanceof GPBEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that two values are equal.
|
||||
*
|
||||
* @param Message $expected The first value to compare
|
||||
* @param Message $actual The second value to compare
|
||||
* @param float|int $delta The allowed numerical distance between two values to
|
||||
* consider them equal
|
||||
* @param bool $canonicalize If set to TRUE, arrays are sorted before
|
||||
* comparison
|
||||
* @param bool $ignoreCase If set to TRUE, upper- and lowercasing is
|
||||
* ignored when comparing string values
|
||||
* @throws ComparisonFailure Thrown when the comparison
|
||||
* fails. Contains information about the
|
||||
* specific errors that lead to the failure.
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false)
|
||||
{
|
||||
// No need to do anything here.
|
||||
}
|
||||
}
|
||||
79
vendor/google/gax/src/Testing/ProtobufMessageComparator.php
vendored
Normal file
79
vendor/google/gax/src/Testing/ProtobufMessageComparator.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\Protobuf\Internal\Message;
|
||||
use SebastianBergmann\Comparator\Comparator;
|
||||
use SebastianBergmann\Comparator\ComparisonFailure;
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ProtobufMessageComparator extends Comparator
|
||||
{
|
||||
/** @var Exporter */
|
||||
protected $exporter;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->exporter = new MessageAwareExporter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the comparator can compare two values.
|
||||
*
|
||||
* @param mixed $expected The first value to compare
|
||||
* @param mixed $actual The second value to compare
|
||||
* @return boolean
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return $expected instanceof Message && $actual instanceof Message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that two values are equal.
|
||||
*
|
||||
* @param Message $expected The first value to compare
|
||||
* @param Message $actual The second value to compare
|
||||
* @param float|int $delta The allowed numerical distance between two values to
|
||||
* consider them equal
|
||||
* @param bool $canonicalize If set to TRUE, arrays are sorted before
|
||||
* comparison
|
||||
* @param bool $ignoreCase If set to TRUE, upper- and lowercasing is
|
||||
* ignored when comparing string values
|
||||
* @throws ComparisonFailure Thrown when the comparison
|
||||
* fails. Contains information about the
|
||||
* specific errors that lead to the failure.
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false)
|
||||
{
|
||||
if ($expected->serializeToString() !== $actual->serializeToString()) {
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
$actual,
|
||||
$this->exporter->shortenedExport($expected),
|
||||
$this->exporter->shortenedExport($actual),
|
||||
false,
|
||||
'Given 2 Message objects are not the same'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
79
vendor/google/gax/src/Testing/ReceivedRequest.php
vendored
Normal file
79
vendor/google/gax/src/Testing/ReceivedRequest.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2016 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
/**
|
||||
* Class ReceivedRequest used to hold the function name and request object of a call
|
||||
* make to a mock gRPC stub.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ReceivedRequest
|
||||
{
|
||||
private $actualCall;
|
||||
|
||||
public function __construct($funcCall, $requestObject, $deserialize = null, $metadata = [], $options = [])
|
||||
{
|
||||
$this->actualCall = [
|
||||
'funcCall' => $funcCall,
|
||||
'request' => $requestObject,
|
||||
'deserialize' => $deserialize,
|
||||
'metadata' => $metadata,
|
||||
'options' => $options,
|
||||
];
|
||||
}
|
||||
|
||||
public function getArray()
|
||||
{
|
||||
return $this->actualCall;
|
||||
}
|
||||
|
||||
public function getFuncCall()
|
||||
{
|
||||
return $this->actualCall['funcCall'];
|
||||
}
|
||||
|
||||
public function getRequestObject()
|
||||
{
|
||||
return $this->actualCall['request'];
|
||||
}
|
||||
|
||||
public function getMetadata()
|
||||
{
|
||||
return $this->actualCall['metadata'];
|
||||
}
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->actualCall['options'];
|
||||
}
|
||||
}
|
||||
72
vendor/google/gax/src/Testing/SerializationTrait.php
vendored
Normal file
72
vendor/google/gax/src/Testing/SerializationTrait.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2017 Google LLC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
namespace Google\ApiCore\Testing;
|
||||
|
||||
use Google\Protobuf\Internal\Message;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
trait SerializationTrait
|
||||
{
|
||||
/**
|
||||
* @param mixed $message
|
||||
* @param mixed $deserialize
|
||||
*/
|
||||
protected function deserializeMessage($message, $deserialize)
|
||||
{
|
||||
if ($message === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($deserialize === null) {
|
||||
return $message;
|
||||
}
|
||||
|
||||
// Proto3 implementation
|
||||
if (is_array($deserialize)) {
|
||||
list($className, $deserializeFunc) = $deserialize;
|
||||
/** @var Message $obj */
|
||||
$obj = new $className();
|
||||
if (method_exists($obj, $deserializeFunc)) {
|
||||
$obj->$deserializeFunc($message);
|
||||
} elseif (is_string($message)) {
|
||||
$obj->mergeFromString($message);
|
||||
}
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
// Protobuf-PHP implementation
|
||||
return call_user_func($deserialize, $message);
|
||||
}
|
||||
}
|
||||
46
vendor/google/gax/src/Testing/mocks.proto
vendored
Normal file
46
vendor/google/gax/src/Testing/mocks.proto
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package google.apicore.testing;
|
||||
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
option php_namespace = "Google\\ApiCore\\Testing";
|
||||
option php_metadata_namespace = "GPBMetadata\\ApiCore\\Testing";
|
||||
|
||||
message MockRequest {
|
||||
string page_token = 1;
|
||||
uint64 page_size = 2;
|
||||
}
|
||||
|
||||
message MockResponse {
|
||||
string name = 1;
|
||||
uint64 number = 2;
|
||||
repeated string resources_list = 3;
|
||||
string next_page_token = 4;
|
||||
map<string, string> resources_map = 5;
|
||||
}
|
||||
|
||||
message MockRequestBody {
|
||||
string name = 1;
|
||||
uint64 number = 2;
|
||||
repeated string repeated_field = 3;
|
||||
MockRequestBody nested_message = 4;
|
||||
google.protobuf.BytesValue bytes_value = 5;
|
||||
google.protobuf.Duration duration_value = 6;
|
||||
google.protobuf.FieldMask field_mask = 7;
|
||||
google.protobuf.Int64Value int64_value = 8;
|
||||
google.protobuf.ListValue list_value = 9;
|
||||
google.protobuf.StringValue string_value = 10;
|
||||
google.protobuf.Struct struct_value = 11;
|
||||
google.protobuf.Timestamp timestamp_value = 12;
|
||||
google.protobuf.Value value_value = 13;
|
||||
oneof oneof_field {
|
||||
string field_1 = 14;
|
||||
string field_2 = 15;
|
||||
string field_3 = 16;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user