11<?php
2+
23namespace Google \Cloud \Samples \BigTable \Tests ;
34
5+ use Google \Cloud \Bigtable \BigtableClient ;
46use PHPUnit \Framework \TestCase ;
57
68use Google \Cloud \Bigtable \Admin \V2 \BigtableInstanceAdminClient ;
1214
1315final class BigTableTest extends TestCase
1416{
15- use TestTrait,ExponentialBackoffTrait;
17+ use TestTrait, ExponentialBackoffTrait;
1618
1719 const INSTANCE_ID_PREFIX = 'php-instance- ' ;
1820 const CLUSTER_ID_PREFIX = 'php-cluster- ' ;
1921 const TABLE_ID_PREFIX = 'php-table- ' ;
2022 private static $ instanceAdminClient ;
2123 private static $ tableAdminClient ;
24+ private static $ bigtableClient ;
2225 private static $ instanceId ;
2326 private static $ clusterId ;
2427
@@ -27,11 +30,14 @@ public static function setUpBeforeClass()
2730 self ::checkProjectEnvVarBeforeClass ();
2831 self ::$ instanceAdminClient = new BigtableInstanceAdminClient ();
2932 self ::$ tableAdminClient = new BigtableTableAdminClient ();
33+ self ::$ bigtableClient = new BigtableClient ([
34+ 'projectId ' => self ::$ projectId ,
35+ ]);
3036
3137 self ::$ instanceId = uniqid (self ::INSTANCE_ID_PREFIX );
3238 self ::$ clusterId = uniqid (self ::CLUSTER_ID_PREFIX );
3339
34- self ::create_production_instance (self ::$ projectId ,self ::$ instanceId ,self ::$ clusterId );
40+ self ::create_production_instance (self ::$ projectId , self ::$ instanceId , self ::$ clusterId );
3541 }
3642
3743 public function setUp ()
@@ -368,16 +374,18 @@ public function testWritingRows()
368374 $ tableId = uniqid (self ::TABLE_ID_PREFIX );
369375 $ tableName = self ::$ tableAdminClient ->tableName (self ::$ projectId , self ::$ instanceId , $ tableId );
370376
371- $ this ->createTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
377+ $ this ->createHWTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
372378 $ this ->checkTable ($ tableName );
373379
374- $ content = self ::runSnippet ('writing_rows ' , [
380+ $ content = self ::runSnippet ('hw_write_rows ' , [
375381 self ::$ projectId ,
376382 self ::$ instanceId ,
377383 $ tableId
378384 ]);
379385
380- $ table = self ::$ tableAdminClient ->table (self ::$ instanceId , self ::$ tableId );
386+ $ table = self ::$ bigtableClient ->table (self ::$ instanceId , $ tableId );
387+ $ columnFamilyId = 'cf1 ' ;
388+ $ column = 'greeting ' ;
381389
382390 $ partial_rows = $ table ->readRows ([])->readAll ();
383391 $ array = [];
@@ -395,16 +403,16 @@ public function testGettingARow()
395403 $ tableId = uniqid (self ::TABLE_ID_PREFIX );
396404 $ tableName = self ::$ tableAdminClient ->tableName (self ::$ projectId , self ::$ instanceId , $ tableId );
397405
398- $ this ->createTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
406+ $ this ->createHWTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
399407 $ this ->checkTable ($ tableName );
400408
401- self ::runSnippet ('writing_rows ' , [
409+ self ::runSnippet ('hw_write_rows ' , [
402410 self ::$ projectId ,
403411 self ::$ instanceId ,
404412 $ tableId
405413 ]);
406414
407- $ content = self ::runSnippet ('getting_a_row ' , [
415+ $ content = self ::runSnippet ('hw_get_with_filter ' , [
408416 self ::$ projectId ,
409417 self ::$ instanceId ,
410418 $ tableId
@@ -421,16 +429,16 @@ public function testScanningAllRows()
421429 $ tableId = uniqid (self ::TABLE_ID_PREFIX );
422430 $ tableName = self ::$ tableAdminClient ->tableName (self ::$ projectId , self ::$ instanceId , $ tableId );
423431
424- $ this ->createTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
432+ $ this ->createHWTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
425433 $ this ->checkTable ($ tableName );
426434
427- self ::runSnippet ('writing_rows ' , [
435+ self ::runSnippet ('hw_write_rows ' , [
428436 self ::$ projectId ,
429437 self ::$ instanceId ,
430438 $ tableId
431439 ]);
432440
433- $ content = self ::runSnippet ('scanning_all_rows ' , [
441+ $ content = self ::runSnippet ('hw_scan_all ' , [
434442 self ::$ projectId ,
435443 self ::$ instanceId ,
436444 $ tableId
@@ -548,6 +556,15 @@ private function createTable($projectId, $instanceId, $clusterId, $tableId)
548556 ]);
549557 }
550558
559+ private function createHWTable ($ projectId , $ instanceId , $ clusterId , $ tableId )
560+ {
561+ self ::runSnippet ('hw_create_table ' , [
562+ $ projectId ,
563+ $ instanceId ,
564+ $ tableId
565+ ]);
566+ }
567+
551568 private function cleanInstance ($ projectId , $ instanceId )
552569 {
553570 $ content = self ::runSnippet ('delete_instance ' , [
0 commit comments