Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Nov 12, 2024
1 parent 508dae8 commit 2fd700f
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 1,322 deletions.
2 changes: 1 addition & 1 deletion Core/tests/Snippet/Iam/IamManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class IamManagerTest extends SnippetTestCase
private $policyData;
private $resource;

private $requestHandler;
private $spannerClient;
private $serializer;
private $iam;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class LongRunningOperationManagerTest extends SnippetTestCase
const NAME = 'operations/foo';
const TYPE = 'test-type';

private $requestHandler;
private $spannerClient;
private $serializer;
private $operation;
private $callables;
Expand Down Expand Up @@ -87,8 +87,7 @@ public function setUp(): void
$this->callables,
$this->lroResponseMappers,
DatabaseAdminClient::class,
self::NAME,
], ['requestHandler', 'serializer']);
self::NAME, );
}

public function testName()
Expand Down
2 changes: 1 addition & 1 deletion Spanner/src/V1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```php
require 'vendor/autoload.php';

use Google\Cloud\Spanner\V1\SpannerClient;
use Google\Cloud\Spanner\V1\Client\SpannerClient;

$spannerClient = new SpannerClient();
try {
Expand Down
2 changes: 0 additions & 2 deletions Spanner/tests/Snippet/ArrayTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
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\V1\Client\SpannerClient;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
Expand All @@ -40,7 +39,6 @@
class ArrayTypeTest extends SnippetTestCase
{
use GrpcTestTrait;
use OperationRefreshTrait;
use ProphecyTrait;

const PROJECT = 'my-awesome-project';
Expand Down
17 changes: 7 additions & 10 deletions Spanner/tests/Snippet/BackupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BackupTest extends SnippetTestCase
const DATABASE = 'my-database';
const BACKUP = 'my-backup';

private $requestHandler;
private $spannerClient;
private $serializer;
private $backup;
private $client;
Expand All @@ -56,28 +56,25 @@ public function setUp(): void
$this->checkAndSkipGrpcTests();

$this->serializer = new Serializer();
$this->client = TestHelpers::stub(
SpannerClient::class,
$this->client = new SpannerClient(
[['projectId' => 'my-project']],
['requestHandler', 'serializer']
);
$this->client->___setProperty('requestHandler', $this->requestHandler->reveal());
$this->client->___setProperty('serializer', $this->serializer);
$this->expireTime = new \DateTime("+ 7 hours");
$this->instance = TestHelpers::stub(Instance::class, [
$this->instance = new Instance(
$this->requestHandler->reveal(),
$this->serializer,
self::PROJECT,
self::INSTANCE
], ['requestHandler', 'serializer']);
);

$this->backup = TestHelpers::stub(Backup::class, [
$this->backup = new Backup(
$this->requestHandler->reveal(),
$this->serializer,
$this->instance,
self::PROJECT,
self::BACKUP,
], ['instance', 'requestHandler', 'serializer']);
self::BACKUP
);
}

public function testClass()
Expand Down
9 changes: 4 additions & 5 deletions Spanner/tests/Snippet/Batch/BatchClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Google\Cloud\Spanner\Tests\Snippet\Batch;

use Google\ApiCore\Serializer;
use Google\Cloud\Core\RequestHandler;
use Google\Cloud\Core\Testing\GrpcTestTrait;
use Google\Cloud\Core\Testing\Snippet\SnippetTestCase;
Expand All @@ -29,7 +30,6 @@
use Google\Cloud\Spanner\Batch\QueryPartition;
use Google\Cloud\Spanner\Database;
use Google\Cloud\Spanner\Operation;
use Google\Cloud\Spanner\Tests\OperationRefreshTrait;
use Google\Cloud\Spanner\Timestamp;
use Google\Cloud\Spanner\V1\Client\SpannerClient;
use Prophecy\Argument;
Expand All @@ -41,13 +41,12 @@
class BatchClientTest extends SnippetTestCase
{
use GrpcTestTrait;
use OperationRefreshTrait;

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';
const TRANSACTION = 'transaction-id';

private $requestHandler;
private $spannerClient;
private $serializer;
private $client;

Expand All @@ -56,10 +55,10 @@ public function setUp(): void
$this->checkAndSkipGrpcTests();

$this->serializer = new Serializer();
$this->client = TestHelpers::stub(BatchClient::class, [
$this->client = new BatchClient(
new Operation($this->requestHandler->reveal(), $this->serializer, false),
self::DATABASE
], ['operation']);
);
}

public function testClass()
Expand Down
4 changes: 1 addition & 3 deletions Spanner/tests/Snippet/Batch/BatchSnapshotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
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\Timestamp;
use Google\Cloud\Spanner\V1\Client\SpannerClient;
use Prophecy\Argument;
Expand All @@ -41,14 +40,13 @@
class BatchSnapshotTest extends SnippetTestCase
{
use GrpcTestTrait;
use OperationRefreshTrait;
use ProphecyTrait;

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';
const TRANSACTION = 'transaction-id';

private $requestHandler;
private $spannerClient;
private $serializer;
private $session;
private $time;
Expand Down
2 changes: 1 addition & 1 deletion Spanner/tests/Snippet/Batch/QueryPartitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class QueryPartitionTest extends SnippetTestCase
const SESSION = 'projects/my-awesome-project/instances/my-instance/databases/my-database/sessions/session-id';
const TRANSACTION = 'transaction-id';

private $requestHandler;
private $spannerClient;
private $serializer;
private $className = QueryPartition::class;
private $sql = 'SELECT 1=1';
Expand Down
2 changes: 1 addition & 1 deletion Spanner/tests/Snippet/Batch/ReadPartitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ReadPartitionTest extends SnippetTestCase
const SESSION = 'projects/my-awesome-project/instances/my-instance/databases/my-database/sessions/session-id';
const TRANSACTION = 'transaction-id';

private $requestHandler;
private $spannerClient;
private $serializer;
private $className = ReadPartition::class;
private $time;
Expand Down
2 changes: 1 addition & 1 deletion Spanner/tests/Snippet/BatchDmlResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BatchDmlResultTest extends SnippetTestCase
use ProphecyTrait;
use TimeTrait;

private $requestHandler;
private $spannerClient;
private $serializer;
private $result;

Expand Down
5 changes: 2 additions & 3 deletions Spanner/tests/Snippet/CommitTimestampTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CommitTimestampTest extends SnippetTestCase

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

private $requestHandler;
private $spannerClient;
private $serializer;

public function setUp(): void
Expand All @@ -49,8 +49,7 @@ public function testClass()
{
$id = 'abc';

$client = TestHelpers::stub(
SpannerClient::class,
$client = new SpannerClient(
[['projectId' => 'my-project']],
['requestHandler', 'serializer']
);
Expand Down
13 changes: 4 additions & 9 deletions Spanner/tests/Snippet/DatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use Google\Cloud\Spanner\Session\Session;
use Google\Cloud\Spanner\Session\SessionPoolInterface;
use Google\Cloud\Spanner\Snapshot;
use Google\Cloud\Spanner\Tests\OperationRefreshTrait;
use Google\Cloud\Spanner\Tests\ResultGeneratorTrait;
use Google\Cloud\Spanner\Timestamp;
use Google\Cloud\Spanner\Transaction;
Expand All @@ -48,7 +47,6 @@
class DatabaseTest extends SnippetTestCase
{
use GrpcTestTrait;
use OperationRefreshTrait;
use ProphecyTrait;
use ResultGeneratorTrait;

Expand All @@ -58,7 +56,7 @@ class DatabaseTest extends SnippetTestCase
const TRANSACTION = 'my-transaction';
const BACKUP = 'my-backup';

private $requestHandler;
private $spannerClient;
private $serializer;
private $database;
private $instance;
Expand All @@ -85,12 +83,11 @@ public function setUp(): void
$sessionPool->clear()->willReturn(null);

$this->serializer = new Serializer();
$this->instance = TestHelpers::stub(Instance::class, [
$this->instance = new Instance(
$this->requestHandler->reveal(),
$this->serializer,
self::PROJECT,
self::INSTANCE
], ['requestHandler', 'serializer']);
self::INSTANCE );

$this->database = TestHelpers::stub(Database::class, [
$this->requestHandler->reveal(),
Expand Down Expand Up @@ -167,9 +164,7 @@ public function testBackups()
);

$this->instance->___setProperty('requestHandler', $this->requestHandler->reveal());
$this->instance->___setProperty('serializer', $this->serializer);

$res = $snippet->invoke('backups');
$res = $snippet->invoke('backups');

$this->assertInstanceOf(ItemIterator::class, $res->returnVal());
$this->assertContainsOnlyInstancesOf(Backup::class, $res->returnVal());
Expand Down
5 changes: 2 additions & 3 deletions Spanner/tests/Snippet/InstanceConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class InstanceConfigurationTest extends SnippetTestCase
const PROJECT = 'my-awesome-project';
const CONFIG = 'regional-europe-west';

private $requestHandler;
private $spannerClient;
private $serializer;
private $config;

Expand All @@ -52,8 +52,7 @@ public function setUp(): void
$this->serializer,
self::PROJECT,
self::CONFIG,
[],
], ['requestHandler', 'serializer']);
[], );
}

public function testClass()
Expand Down
Loading

0 comments on commit 2fd700f

Please sign in to comment.