@@ -47,23 +47,17 @@ public static function setUpBeforeClass()
4747 if (!$ projectId = getenv ('GOOGLE_PROJECT_ID ' )) {
4848 self ::markTestSkipped ('GOOGLE_PROJECT_ID must be set. ' );
4949 }
50+ if (!$ instanceId = getenv ('GOOGLE_SPANNER_INSTANCE_ID ' )) {
51+ self ::markTestSkipped ('GOOGLE_PROJECT_ID must be set. ' );
52+ }
5053
5154 $ spanner = new SpannerClient ([
5255 'projectId ' => $ projectId ,
5356 ]);
5457
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 );
6761 }
6862
6963 public function testCreateDatabase ()
@@ -374,8 +368,10 @@ private function runCommand($commandName)
374368
375369 public static function tearDownAfterClass ()
376370 {
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 ();
379375 }
380376 }
381377}
0 commit comments