diff --git a/tests/unit/Core/GPBGrpcRequestWrapperTest.php b/tests/unit/Core/GPBGrpcRequestWrapperTest.php index bca540e613d9..b965e2dda5f4 100644 --- a/tests/unit/Core/GPBGrpcRequestWrapperTest.php +++ b/tests/unit/Core/GPBGrpcRequestWrapperTest.php @@ -65,6 +65,9 @@ function ($test, $options) use ($response, $requestOptions) { public function responseProvider() { + if ($this->shouldSkipGrpcTests()) { + return []; + } $expectedMessage = ['successful' => 'request']; $message = $this->prophesize(Message::class); $serializer = $this->prophesize(Serializer::class); diff --git a/tests/unit/Spanner/BytesTest.php b/tests/unit/Spanner/BytesTest.php index d91b19ccfd34..324456c1c678 100644 --- a/tests/unit/Spanner/BytesTest.php +++ b/tests/unit/Spanner/BytesTest.php @@ -18,14 +18,22 @@ namespace Google\Cloud\Tests\Unit\Spanner; use Google\Cloud\Spanner\Bytes; +use Google\Cloud\Tests\GrpcTestTrait; /** * @group spanner */ class BytesTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + private $content = 'hello'; + public function setUp() + { + $this->checkAndSkipGrpcTests(); + } + public function testGet() { $bytes = new Bytes($this->content); diff --git a/tests/unit/Spanner/DatabaseTest.php b/tests/unit/Spanner/DatabaseTest.php index 0f5a1a16660f..a4b1ef6cda3f 100644 --- a/tests/unit/Spanner/DatabaseTest.php +++ b/tests/unit/Spanner/DatabaseTest.php @@ -36,6 +36,7 @@ use Google\Cloud\Spanner\Timestamp; use Google\Cloud\Spanner\Transaction; use Google\Cloud\Spanner\ValueMapper; +use Google\Cloud\Tests\GrpcTestTrait; use Prophecy\Argument; /** @@ -43,6 +44,8 @@ */ class DatabaseTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + const PROJECT = 'my-awesome-project'; const DATABASE = 'my-database'; const INSTANCE = 'my-instance'; @@ -58,6 +61,8 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->connection = $this->prophesize(ConnectionInterface::class); $this->instance = $this->prophesize(Instance::class); $this->sessionPool = $this->prophesize(SessionPoolInterface::class); diff --git a/tests/unit/Spanner/DateTest.php b/tests/unit/Spanner/DateTest.php index 9ccb45b8d717..e7e2034dbf51 100644 --- a/tests/unit/Spanner/DateTest.php +++ b/tests/unit/Spanner/DateTest.php @@ -18,17 +18,22 @@ namespace Google\Cloud\Tests\Unit\Spanner; use Google\Cloud\Spanner\Date; +use Google\Cloud\Tests\GrpcTestTrait; /** * @group spanner */ class DateTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + private $dt; private $date; public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->dt = new \DateTime('1989-10-11'); $this->date = new Date($this->dt); } diff --git a/tests/unit/Spanner/InstanceConfigurationTest.php b/tests/unit/Spanner/InstanceConfigurationTest.php index f8515a4a0d6c..e654d9687439 100644 --- a/tests/unit/Spanner/InstanceConfigurationTest.php +++ b/tests/unit/Spanner/InstanceConfigurationTest.php @@ -21,6 +21,7 @@ use Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminClient; use Google\Cloud\Spanner\InstanceConfiguration; use Google\Cloud\Spanner\Connection\ConnectionInterface; +use Google\Cloud\Tests\GrpcTestTrait; use Prophecy\Argument; /** @@ -29,6 +30,8 @@ */ class InstanceConfigurationTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + const PROJECT_ID = 'test-project'; const NAME = 'test-config'; @@ -37,6 +40,8 @@ class InstanceConfigurationTest extends \PHPUnit_Framework_TestCase public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->connection = $this->prophesize(ConnectionInterface::class); $this->configuration = \Google\Cloud\Dev\stub(InstanceConfiguration::class, [ $this->connection->reveal(), diff --git a/tests/unit/Spanner/InstanceTest.php b/tests/unit/Spanner/InstanceTest.php index 7542546fafa7..e313e4dbc95b 100644 --- a/tests/unit/Spanner/InstanceTest.php +++ b/tests/unit/Spanner/InstanceTest.php @@ -29,6 +29,7 @@ use Google\Cloud\Spanner\Database; use Google\Cloud\Spanner\Instance; use Google\Cloud\Spanner\Session\SessionPoolInterface; +use Google\Cloud\Tests\GrpcTestTrait; use Prophecy\Argument; /** @@ -37,6 +38,8 @@ */ class InstanceTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + const PROJECT_ID = 'test-project'; const NAME = 'instance-name'; @@ -45,6 +48,8 @@ class InstanceTest extends \PHPUnit_Framework_TestCase public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->connection = $this->prophesize(ConnectionInterface::class); $this->instance = \Google\Cloud\Dev\stub(Instance::class, [ $this->connection->reveal(), diff --git a/tests/unit/Spanner/KeyRangeTest.php b/tests/unit/Spanner/KeyRangeTest.php index 0b8703083455..291cd81203d8 100644 --- a/tests/unit/Spanner/KeyRangeTest.php +++ b/tests/unit/Spanner/KeyRangeTest.php @@ -18,16 +18,21 @@ namespace Google\Cloud\Tests\Unit\Spanner; use Google\Cloud\Spanner\KeyRange; +use Google\Cloud\Tests\GrpcTestTrait; /** * @group spanner */ class KeyRangeTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + private $range; public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->range = new KeyRange; } diff --git a/tests/unit/Spanner/OperationTest.php b/tests/unit/Spanner/OperationTest.php index e1437da9aebe..90b208c4326c 100644 --- a/tests/unit/Spanner/OperationTest.php +++ b/tests/unit/Spanner/OperationTest.php @@ -29,6 +29,7 @@ use Google\Cloud\Spanner\Timestamp; use Google\Cloud\Spanner\Transaction; use Google\Cloud\Spanner\ValueMapper; +use Google\Cloud\Tests\GrpcTestTrait; use Prophecy\Argument; /** @@ -36,6 +37,8 @@ */ class OperationTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + const SESSION = 'my-session-id'; const TRANSACTION = 'my-transaction-id'; const DATABASE = 'my-database'; @@ -47,6 +50,8 @@ class OperationTest extends \PHPUnit_Framework_TestCase public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->connection = $this->prophesize(ConnectionInterface::class); $this->operation = \Google\Cloud\Dev\stub(Operation::class, [ diff --git a/tests/unit/Spanner/SnapshotTest.php b/tests/unit/Spanner/SnapshotTest.php index e846882c5f9a..db45dd5f553d 100644 --- a/tests/unit/Spanner/SnapshotTest.php +++ b/tests/unit/Spanner/SnapshotTest.php @@ -21,6 +21,7 @@ use Google\Cloud\Spanner\Session\Session; use Google\Cloud\Spanner\Snapshot; use Google\Cloud\Spanner\Timestamp; +use Google\Cloud\Tests\GrpcTestTrait; use Prophecy\Argument; /** @@ -28,11 +29,15 @@ */ class SnapshotTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + private $timestamp; private $snapshot; public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->timestamp = new Timestamp(new \DateTime); $args = [ diff --git a/tests/unit/Spanner/TimestampTest.php b/tests/unit/Spanner/TimestampTest.php index 62d35c94d8f7..dbafb0b24a3f 100644 --- a/tests/unit/Spanner/TimestampTest.php +++ b/tests/unit/Spanner/TimestampTest.php @@ -18,17 +18,22 @@ namespace Google\Cloud\Tests\Unit\Spanner; use Google\Cloud\Spanner\Timestamp; +use Google\Cloud\Tests\GrpcTestTrait; /** * @group spanner */ class TimestampTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + private $dt; private $ts; public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->dt = new \DateTime('1989-10-11 08:58:00 +00:00'); $this->ts = new Timestamp($this->dt); } diff --git a/tests/unit/Spanner/TransactionConfigurationTraitTest.php b/tests/unit/Spanner/TransactionConfigurationTraitTest.php index da1119bb9060..54a2bac77e85 100644 --- a/tests/unit/Spanner/TransactionConfigurationTraitTest.php +++ b/tests/unit/Spanner/TransactionConfigurationTraitTest.php @@ -21,12 +21,15 @@ use Google\Cloud\Spanner\Session\SessionPoolInterface; use Google\Cloud\Spanner\Timestamp; use Google\Cloud\Spanner\TransactionConfigurationTrait; +use Google\Cloud\Tests\GrpcTestTrait; /** * @group spanner */ class TransactionConfigurationTraitTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + const TRANSACTION = 'my-transaction'; const TIMESTAMP = '2017-01-09T18:05:22.534799Z'; const NANOS = '534799'; @@ -38,6 +41,8 @@ class TransactionConfigurationTraitTest extends \PHPUnit_Framework_TestCase public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->impl = new TransactionConfigurationTraitImplementation; $this->ts = new Timestamp(new \DateTime(self::TIMESTAMP), self::NANOS); $this->duration = new Duration(10,1); diff --git a/tests/unit/Spanner/TransactionTest.php b/tests/unit/Spanner/TransactionTest.php index 744b3d337021..fbbb0d6a923a 100644 --- a/tests/unit/Spanner/TransactionTest.php +++ b/tests/unit/Spanner/TransactionTest.php @@ -28,6 +28,7 @@ use Google\Cloud\Spanner\Timestamp; use Google\Cloud\Spanner\Transaction; use Google\Cloud\Spanner\ValueMapper; +use Google\Cloud\Tests\GrpcTestTrait; use Prophecy\Argument; /** @@ -35,6 +36,8 @@ */ class TransactionTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + const TIMESTAMP = '2017-01-09T18:05:22.534799Z'; const PROJECT = 'my-awesome-project'; @@ -53,6 +56,8 @@ class TransactionTest extends \PHPUnit_Framework_TestCase public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->connection = $this->prophesize(ConnectionInterface::class); $this->operation = new Operation($this->connection->reveal(), false); diff --git a/tests/unit/Spanner/TransactionTypeTest.php b/tests/unit/Spanner/TransactionTypeTest.php index 491449f1739b..5c947c558bfd 100644 --- a/tests/unit/Spanner/TransactionTypeTest.php +++ b/tests/unit/Spanner/TransactionTypeTest.php @@ -30,6 +30,7 @@ use Google\Cloud\Spanner\Timestamp; use Google\Cloud\Spanner\Transaction; use Google\Cloud\Spanner\V1\SpannerClient; +use Google\Cloud\Tests\GrpcTestTrait; use Prophecy\Argument; /** @@ -37,6 +38,8 @@ */ class TransactionTypeTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + use ResultTestTrait; const PROJECT = 'my-project'; @@ -51,6 +54,8 @@ class TransactionTypeTest extends \PHPUnit_Framework_TestCase public function setUp() { + $this->checkAndSkipGrpcTests(); + $this->timestamp = (new \DateTimeImmutable)->format(Timestamp::FORMAT); $this->connection = $this->prophesize(ConnectionInterface::class); diff --git a/tests/unit/Spanner/ValueMapperTest.php b/tests/unit/Spanner/ValueMapperTest.php index 83f9efcf10a9..e1e02b089df2 100644 --- a/tests/unit/Spanner/ValueMapperTest.php +++ b/tests/unit/Spanner/ValueMapperTest.php @@ -24,18 +24,22 @@ use Google\Cloud\Spanner\Result; use Google\Cloud\Spanner\Timestamp; use Google\Cloud\Spanner\ValueMapper; +use Google\Cloud\Tests\GrpcTestTrait; /** * @group spanner */ class ValueMapperTest extends \PHPUnit_Framework_TestCase { + use GrpcTestTrait; + const FORMAT_TEST_VALUE = 'abc'; private $mapper; public function setUp() { + $this->checkAndSkipGrpcTests(); $this->mapper = new ValueMapper(false); }