Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix compatibility with phpspec/prophecy v1.10 #2525

Merged
merged 3 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions Firestore/tests/Unit/FirestoreClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,23 +513,6 @@ public function testRunTransactionExceedsMaxRetriesLowerLimit()
}, ['maxRetries' => 2]);
}

/**
* @expectedException RuntimeException
*/
public function testInvalidNestedTransaction()
{
$transactionId = 'foobar';
$this->connection->beginTransaction(Argument::any())->willReturn([
'transaction' => $transactionId
]);

$this->client->___setProperty('connection', $this->connection->reveal());

$this->client->runTransaction(function ($t) {
$this->client->runTransaction($this->noop());
});
}

public function testGeoPoint()
{
$lat = 1.1;
Expand Down
5 changes: 3 additions & 2 deletions Spanner/tests/Snippet/ArrayTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminClient;
use Google\Cloud\Spanner\ArrayType;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Spanner\Database;
use Google\Cloud\Spanner\Instance;
use Google\Cloud\Spanner\Session\Session;
use Google\Cloud\Spanner\Session\SessionPoolInterface;
use Google\Cloud\Spanner\StructType;
use Google\Cloud\Spanner\Tests\OperationRefreshTrait;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Prophecy\Argument;

/**
Expand All @@ -40,6 +40,7 @@ class ArrayTypeTest extends SnippetTestCase
{
use GrpcTestTrait;
use OperationRefreshTrait;
use StubCreationTrait;

const PROJECT = 'my-awesome-project';
const DATABASE = 'my-database';
Expand All @@ -64,7 +65,7 @@ public function setUp()
$sessionPool->setDatabase(Argument::any())
->willReturn(null);

$this->connection = $this->prophesize(ConnectionInterface::class);
$this->connection = $this->getConnStub();
$this->database = TestHelpers::stub(Database::class, [
$this->connection->reveal(),
$instance->reveal(),
Expand Down
4 changes: 3 additions & 1 deletion Spanner/tests/Snippet/Batch/BatchClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Google\Cloud\Spanner\Database;
use Google\Cloud\Spanner\Operation;
use Google\Cloud\Spanner\Tests\OperationRefreshTrait;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Google\Cloud\Spanner\Timestamp;
use Prophecy\Argument;

Expand All @@ -40,6 +41,7 @@ class BatchClientTest extends SnippetTestCase
{
use GrpcTestTrait;
use OperationRefreshTrait;
use StubCreationTrait;

const DATABASE = 'projects/my-awesome-project/instances/my-instance/databases/my-database';
const SESSION = 'projects/my-awesome-project/instances/my-instance/databases/my-database/sessions/session-id';
Expand All @@ -52,7 +54,7 @@ public function setUp()
{
$this->checkAndSkipGrpcTests();

$this->connection = $this->prophesize(ConnectionInterface::class);
$this->connection = $this->getConnStub();
$this->client = TestHelpers::stub(BatchClient::class, [
new Operation($this->connection->reveal(), false),
self::DATABASE
Expand Down
5 changes: 3 additions & 2 deletions Spanner/tests/Snippet/Batch/BatchSnapshotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
use Google\Cloud\Spanner\Batch\BatchSnapshot;
use Google\Cloud\Spanner\Batch\PartitionInterface;
use Google\Cloud\Spanner\Batch\QueryPartition;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Spanner\Database;
use Google\Cloud\Spanner\Operation;
use Google\Cloud\Spanner\Result;
use Google\Cloud\Spanner\Session\Session;
use Google\Cloud\Spanner\Tests\OperationRefreshTrait;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Google\Cloud\Spanner\Timestamp;
use Google\Cloud\Spanner\V1\SpannerClient;
use Prophecy\Argument;
Expand All @@ -42,6 +42,7 @@ class BatchSnapshotTest extends SnippetTestCase
{
use GrpcTestTrait;
use OperationRefreshTrait;
use StubCreationTrait;

const DATABASE = 'projects/my-awesome-project/instances/my-instance/databases/my-database';
const SESSION = 'projects/my-awesome-project/instances/my-instance/databases/my-database/sessions/session-id';
Expand All @@ -56,7 +57,7 @@ public function setUp()
{
$this->checkAndSkipGrpcTests();

$this->connection = $this->prophesize(ConnectionInterface::class);
$this->connection = $this->getConnStub();

$sessData = SpannerClient::parseName(self::SESSION, 'session');
$this->session = $this->prophesize(Session::class);
Expand Down
5 changes: 3 additions & 2 deletions Spanner/tests/Snippet/Batch/QueryPartitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Spanner\Batch\BatchClient;
use Google\Cloud\Spanner\Batch\QueryPartition;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Spanner\Operation;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Google\Cloud\Spanner\Timestamp;
use Prophecy\Argument;

Expand All @@ -35,6 +35,7 @@ class QueryPartitionTest extends SnippetTestCase
{
use GrpcTestTrait;
use PartitionSharedSnippetTestTrait;
use StubCreationTrait;

const DATABASE = 'projects/my-awesome-project/instances/my-instance/databases/my-database';
const SESSION = 'projects/my-awesome-project/instances/my-instance/databases/my-database/sessions/session-id';
Expand All @@ -54,7 +55,7 @@ public function setUp()

public function testClass()
{
$connection = $this->prophesize(ConnectionInterface::class);
$connection = $this->getConnStub();
$connection->createSession(Argument::any())
->shouldBeCalledTimes(1)
->willReturn([
Expand Down
5 changes: 3 additions & 2 deletions Spanner/tests/Snippet/Batch/ReadPartitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Spanner\Batch\BatchClient;
use Google\Cloud\Spanner\Batch\ReadPartition;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Spanner\KeySet;
use Google\Cloud\Spanner\Operation;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Google\Cloud\Spanner\Timestamp;
use Prophecy\Argument;

Expand All @@ -38,6 +38,7 @@ class ReadPartitionTest extends SnippetTestCase
use PartitionSharedSnippetTestTrait {
provideGetters as private getters;
}
use StubCreationTrait;

const DATABASE = 'projects/my-awesome-project/instances/my-instance/databases/my-database';
const SESSION = 'projects/my-awesome-project/instances/my-instance/databases/my-database/sessions/session-id';
Expand All @@ -62,7 +63,7 @@ public function setUp()

public function testClass()
{
$connection = $this->prophesize(ConnectionInterface::class);
$connection = $this->getConnStub();
$connection->createSession(Argument::any())
->shouldBeCalledTimes(1)
->willReturn([
Expand Down
17 changes: 9 additions & 8 deletions Spanner/tests/Snippet/BatchDmlResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,26 @@

namespace Google\Cloud\Spanner\Tests\Snippet;

use Prophecy\Argument;
use Google\Cloud\Core\LongRunning\LongRunningConnectionInterface;
use Google\Cloud\Core\Testing\GrpcTestTrait;
use Google\Cloud\Core\Testing\Snippet\SnippetTestCase;
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Core\TimeTrait;
use Google\Cloud\Spanner\BatchDmlResult;
use Google\Cloud\Spanner\Database;
use Google\Cloud\Spanner\Instance;
use Google\Cloud\Spanner\BatchDmlResult;
use Google\Cloud\Spanner\Session\Session;
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Core\Testing\GrpcTestTrait;
use Google\Cloud\Core\Testing\Snippet\SnippetTestCase;
use Google\Cloud\Spanner\Session\SessionPoolInterface;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Core\LongRunning\LongRunningConnectionInterface;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Prophecy\Argument;

/**
* @group spanner
*/
class BatchDmlResultTest extends SnippetTestCase
{
use GrpcTestTrait;
use StubCreationTrait;
use TimeTrait;

private $result;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function setUp()

public function testClass()
{
$connection = $this->prophesize(ConnectionInterface::class);
$connection = $this->getConnStub();
$connection->executeBatchDml(Argument::any())
->shouldBeCalled()
->willReturn([
Expand Down
5 changes: 3 additions & 2 deletions Spanner/tests/Snippet/CommitTimestampTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Core\Timestamp;
use Google\Cloud\Spanner\CommitTimestamp;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Spanner\SpannerClient;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Prophecy\Argument;

/**
Expand All @@ -33,6 +33,7 @@
class CommitTimestampTest extends SnippetTestCase
{
use GrpcTestTrait;
use StubCreationTrait;

const SESSION = 'projects/my-awesome-project/instances/my-instance/databases/my-database/sessions/session-id';

Expand All @@ -46,7 +47,7 @@ public function testClass()
$id = 'abc';

$client = TestHelpers::stub(SpannerClient::class);
$conn = $this->prophesize(ConnectionInterface::class);
$conn = $this->getConnStub();
$conn->createSession(Argument::any())
->willReturn([
'name' => self::SESSION
Expand Down
5 changes: 3 additions & 2 deletions Spanner/tests/Snippet/DatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient;
use Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminClient;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Spanner\Database;
use Google\Cloud\Spanner\Instance;
use Google\Cloud\Spanner\KeySet;
Expand All @@ -36,6 +35,7 @@
use Google\Cloud\Spanner\Snapshot;
use Google\Cloud\Spanner\Tests\OperationRefreshTrait;
use Google\Cloud\Spanner\Tests\ResultGeneratorTrait;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Google\Cloud\Spanner\Timestamp;
use Google\Cloud\Spanner\Transaction;
use Prophecy\Argument;
Expand All @@ -49,6 +49,7 @@ class DatabaseTest extends SnippetTestCase
use GrpcTestTrait;
use OperationRefreshTrait;
use ResultGeneratorTrait;
use StubCreationTrait;

const PROJECT = 'my-awesome-project';
const DATABASE = 'my-database';
Expand All @@ -74,7 +75,7 @@ public function setUp()
->willReturn(null);
$sessionPool->clear()->willReturn(null);

$this->connection = $this->prophesize(ConnectionInterface::class);
$this->connection = $this->getConnStub();
$this->database = TestHelpers::stub(Database::class, [
$this->connection->reveal(),
$instance->reveal(),
Expand Down
5 changes: 3 additions & 2 deletions Spanner/tests/Snippet/InstanceConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
use Google\Cloud\Core\Testing\Snippet\SnippetTestCase;
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminClient;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Spanner\InstanceConfiguration;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Prophecy\Argument;

/**
Expand All @@ -32,6 +32,7 @@
class InstanceConfigurationTest extends SnippetTestCase
{
use GrpcTestTrait;
use StubCreationTrait;

const PROJECT = 'my-awesome-project';
const CONFIG = 'regional-europe-west';
Expand All @@ -43,7 +44,7 @@ public function setUp()
{
$this->checkAndSkipGrpcTests();

$this->connection = $this->prophesize(ConnectionInterface::class);
$this->connection = $this->getConnStub();
$this->config = TestHelpers::stub(InstanceConfiguration::class, [
$this->connection->reveal(),
self::PROJECT,
Expand Down
5 changes: 3 additions & 2 deletions Spanner/tests/Snippet/InstanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient;
use Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminClient;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Spanner\Database;
use Google\Cloud\Spanner\Instance;
use Google\Cloud\Spanner\InstanceConfiguration;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Prophecy\Argument;

/**
Expand All @@ -39,6 +39,7 @@
class InstanceTest extends SnippetTestCase
{
use GrpcTestTrait;
use StubCreationTrait;

const PROJECT = 'my-awesome-project';
const INSTANCE = 'my-instance';
Expand All @@ -51,7 +52,7 @@ public function setUp()
{
$this->checkAndSkipGrpcTests();

$this->connection = $this->prophesize(ConnectionInterface::class);
$this->connection = $this->getConnStub();
$this->instance = TestHelpers::stub(Instance::class, [
$this->connection->reveal(),
$this->prophesize(LongRunningConnectionInterface::class)->reveal(),
Expand Down
5 changes: 3 additions & 2 deletions Spanner/tests/Snippet/SnapshotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
use Google\Cloud\Core\Testing\GrpcTestTrait;
use Google\Cloud\Core\Testing\Snippet\SnippetTestCase;
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Spanner\Database;
use Google\Cloud\Spanner\Operation;
use Google\Cloud\Spanner\Session\Session;
use Google\Cloud\Spanner\Snapshot;
use Google\Cloud\Spanner\Tests\OperationRefreshTrait;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Google\Cloud\Spanner\Timestamp;

/**
Expand All @@ -35,6 +35,7 @@ class SnapshotTest extends SnippetTestCase
{
use GrpcTestTrait;
use OperationRefreshTrait;
use StubCreationTrait;

const TRANSACTION = 'my-transaction';

Expand All @@ -45,7 +46,7 @@ public function setUp()
{
$this->checkAndSkipGrpcTests();

$this->connection = $this->prophesize(ConnectionInterface::class);
$this->connection = $this->getConnStub();
$operation = $this->prophesize(Operation::class);
$session = $this->prophesize(Session::class);

Expand Down
5 changes: 3 additions & 2 deletions Spanner/tests/Snippet/SpannerClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use Google\Cloud\Spanner\Batch\BatchClient;
use Google\Cloud\Spanner\Bytes;
use Google\Cloud\Spanner\CommitTimestamp;
use Google\Cloud\Spanner\Connection\ConnectionInterface;
use Google\Cloud\Spanner\Database;
use Google\Cloud\Spanner\Date;
use Google\Cloud\Spanner\Duration;
Expand All @@ -36,6 +35,7 @@
use Google\Cloud\Spanner\KeyRange;
use Google\Cloud\Spanner\KeySet;
use Google\Cloud\Spanner\SpannerClient;
use Google\Cloud\Spanner\Tests\StubCreationTrait;
use Google\Cloud\Spanner\Timestamp;
use Prophecy\Argument;

Expand All @@ -45,6 +45,7 @@
class SpannerClientTest extends SnippetTestCase
{
use GrpcTestTrait;
use StubCreationTrait;

const PROJECT = 'my-awesome-project';
const CONFIG = 'foo';
Expand All @@ -57,7 +58,7 @@ public function setUp()
{
$this->checkAndSkipGrpcTests();

$this->connection = $this->prophesize(ConnectionInterface::class);
$this->connection = $this->getConnStub();
$this->client = TestHelpers::stub(SpannerClient::class);
$this->client->___setProperty('connection', $this->connection->reveal());
}
Expand Down
Loading