tests/Keboola/GoogleSheetsWriter/FunctionalTest.php
/**
     * Create New Spreadsheet using sync action
     */
Create New Spreadsheet using sync action
Create New Spreadsheet using sync action
public function testSyncActionGetSpreadsheet() : void
    {
        $this->prepareDataFiles();
        $gdFile = $this->client->createFile(
            $this->dataPath . '/in/tables/titanic_1.csv',
            'titanic',
            [
                'parents' => [getenv('GOOGLE_DRIVE_FOLDER')],
                'mimeType' => Client::MIME_TYPE_SPREADSHEET,
            ]
        );
        $config = $this->prepareConfig();
        $config['action'] = 'getSpreadsheet';
        $config['parameters']['tables'][] = [
            'id' => 0,
            'title' => 'titanic',
            'fileId' => $gdFile['id'],
            'enabled' => true,
            'folder' => ['id' => getenv('GOOGLE_DRIVE_FOLDER')],
            'action' => ConfigDefinition::ACTION_UPDATE,
        ];
        $process = $this->runProcess($config);
        $this->assertEquals(0, $process->getExitCode(), $process->getErrorOutput());
        $response = json_decode($process->getOutput(), true);
        $this->assertEquals($gdFile['id'], $response['spreadsheet']['spreadsheetId']);
        $this->client->deleteFile($gdFile['id']);
    }
public function testSyncActionGetSpreadsheet ( ) : void { $ this -> prepareDataFiles ( ) ; $ gdFile = $ this -> client -> createFile ( $ this -> dataPath . '/in/tables/titanic_1.csv' , 'titanic' , [ 'parents' => [ getenv ( 'GOOGLE_DRIVE_FOLDER' ) ] , 'mimeType' => Client :: MIME_TYPE_SPREADSHEET , ] ) ; $ config = $ this -> prepareConfig ( ) ; $ config [ 'action' ] = 'getSpreadsheet' ; $ config [ 'parameters' ] [ 'tables' ] [ ] = [ 'id' => 0 , 'title' => 'titanic' , 'fileId' => $ gdFile [ 'id' ] , 'enabled' => true , 'folder' => [ 'id' => getenv ( 'GOOGLE_DRIVE_FOLDER' ) ] , 'action' => ConfigDefinition :: ACTION_UPDATE , ] ; $ process = $ this -> runProcess ( $ config ) ; $ this -> assertEquals ( 0 , $ process -> getExitCode ( ) , $ process -> getErrorOutput ( ) ) ; $ response = json_decode ( $ process -> getOutput ( ) , true ) ; $ this -> assertEquals ( $ gdFile [ 'id' ] , $ response [ 'spreadsheet' ] [ 'spreadsheetId' ] ) ; $ this -> client -> deleteFile ( $ gdFile [ 'id' ] ) ; }
Create New Spreadsheet using sync action
Create New Spreadsheet using sync action
// create spreadsheet