@@ -47,23 +47,17 @@ public static function setUpBeforeClass()
47
47
if (!$ projectId = getenv ('GOOGLE_PROJECT_ID ' )) {
48
48
self ::markTestSkipped ('GOOGLE_PROJECT_ID must be set. ' );
49
49
}
50
+ if (!$ instanceId = getenv ('GOOGLE_SPANNER_INSTANCE_ID ' )) {
51
+ self ::markTestSkipped ('GOOGLE_PROJECT_ID must be set. ' );
52
+ }
50
53
51
54
$ spanner = new SpannerClient ([
52
55
'projectId ' => $ projectId ,
53
56
]);
54
57
55
- self ::$ instanceId = self ::$ databaseId = 'test- ' . time () . rand ();
56
- $ configurationId = "projects/ $ projectId/instanceConfigs/regional-us-central1 " ;
57
-
58
- $ configuration = $ spanner ->instanceConfiguration ($ configurationId );
59
- $ instance = $ spanner ->instance (self ::$ instanceId );
60
-
61
- $ operation = $ instance ->create ($ configuration );
62
- if (!$ operation ->pollUntilComplete ()) {
63
- throw new \Exception ($ operation ->error ()['message ' ]);
64
- }
65
-
66
- self ::$ instance = $ instance ;
58
+ self ::$ databaseId = 'test- ' . time () . rand ();
59
+ self ::$ instanceId = $ instanceId ;
60
+ self ::$ instance = $ spanner ->instance (self ::$ instanceId );
67
61
}
68
62
69
63
public function testCreateDatabase ()
@@ -374,8 +368,10 @@ private function runCommand($commandName)
374
368
375
369
public static function tearDownAfterClass ()
376
370
{
377
- if (self ::$ instance && !getenv ('GOOGLE_SPANNER_KEEP_INSTANCE ' )) {
378
- self ::$ instance ->delete ();
371
+ if (self ::$ instance ) {
372
+ // Clean up database
373
+ $ database = self ::$ instance ->database (self ::$ databaseId );
374
+ $ database ->drop ();
379
375
}
380
376
}
381
377
}
0 commit comments