@@ -99,8 +99,8 @@ public function testCreateAndDeleteTable()
9999 {
100100 $ tempTableId = sprintf ('test_table_%s ' , time ());
101101 $ fields = json_encode ([
102- ['name ' => 'name ' , 'type ' => 'string ' , 'mode ' => 'nullable ' ],
103- ['name ' => 'title ' , 'type ' => 'string ' , 'mode ' => 'nullable ' ]
102+ ['name ' => 'name ' , 'type ' => 'string ' , 'mode ' => 'nullable ' ],
103+ ['name ' => 'title ' , 'type ' => 'string ' , 'mode ' => 'nullable ' ]
104104 ]);
105105 $ output = $ this ->runFunctionSnippet ('create_table ' , [
106106 self ::$ datasetId ,
@@ -352,8 +352,8 @@ public function testAddColumnLoadAppend()
352352 {
353353 $ tableId = $ this ->createTempTable ();
354354 $ output = $ this ->runFunctionSnippet ('add_column_load_append ' , [
355- self ::$ datasetId ,
356- $ tableId
355+ self ::$ datasetId ,
356+ $ tableId
357357 ]);
358358
359359 $ this ->assertStringContainsString ('name ' , $ output );
@@ -365,14 +365,32 @@ public function testAddColumnQueryAppend()
365365 {
366366 $ tableId = $ this ->createTempTable ();
367367 $ output = $ this ->runFunctionSnippet ('add_column_query_append ' , [
368- self ::$ datasetId ,
369- $ tableId
368+ self ::$ datasetId ,
369+ $ tableId
370370 ]);
371371 $ this ->assertStringContainsString ('name ' , $ output );
372372 $ this ->assertStringContainsString ('title ' , $ output );
373373 $ this ->assertStringContainsString ('description ' , $ output );
374374 }
375375
376+ public function testUndeleteTable ()
377+ {
378+ // Create a base table
379+ $ sourceTableId = $ this ->createTempTable ();
380+
381+ // run the sample
382+ $ restoredTableId = uniqid ('restored_ ' );
383+ $ output = $ this ->runFunctionSnippet ('undelete_table ' , [
384+ self ::$ datasetId ,
385+ $ sourceTableId ,
386+ $ restoredTableId ,
387+ ]);
388+
389+ $ restoredTable = self ::$ dataset ->table ($ restoredTableId );
390+ $ this ->assertStringContainsString ('Snapshot restored successfully ' , $ output );
391+ $ this ->verifyTable ($ restoredTable , 'Brent Shaffer ' , 3 );
392+ }
393+
376394 private function runFunctionSnippet ($ sampleName , $ params = [])
377395 {
378396 array_unshift ($ params , self ::$ projectId );
@@ -386,8 +404,8 @@ private function createTempEmptyTable()
386404 {
387405 $ tempTableId = sprintf ('test_table_%s_%s ' , time (), rand ());
388406 $ fields = json_encode ([
389- ['name ' => 'name ' , 'type ' => 'string ' , 'mode ' => 'nullable ' ],
390- ['name ' => 'title ' , 'type ' => 'string ' , 'mode ' => 'nullable ' ]
407+ ['name ' => 'name ' , 'type ' => 'string ' , 'mode ' => 'nullable ' ],
408+ ['name ' => 'title ' , 'type ' => 'string ' , 'mode ' => 'nullable ' ]
391409 ]);
392410 $ this ->runFunctionSnippet ('create_table ' , [
393411 self ::$ datasetId ,
0 commit comments