コード例 #1
0
 public function testTablesConfiguration()
 {
     $tables = $this->client->getTables(FUNCTIONAL_WRITER_ID);
     $this->assertArrayHasKey('tables', $tables);
     $this->assertGreaterThanOrEqual(1, $tables['tables']);
     $this->assertArrayHasKey('id', $tables['tables'][0]);
     $this->assertArrayHasKey('bucket', $tables['tables'][0]);
     $this->assertTrue(isset($tables['tables'][0]['name']) || isset($tables['tables'][0]['title']));
     $this->assertArrayHasKey('identifier', $tables['tables'][0]);
     $tableId = $tables['tables'][0]['id'];
     $tableName = isset($tables['tables'][0]['name']) ? $tables['tables'][0]['name'] : $tables['tables'][0]['title'];
     $table = $this->client->getTable(FUNCTIONAL_WRITER_ID, $tableId);
     $this->assertArrayHasKey('table', $table);
     $this->assertArrayHasKey('id', $table['table']);
     $this->assertTrue(isset($table['table']['name']) || isset($table['table']['title']));
     $this->assertArrayHasKey('columns', $table['table']);
     $this->assertGreaterThanOrEqual(1, $table['table']['columns']);
     $this->assertEquals($tableName, $table['table']['title']);
     $this->assertArrayHasKey('id', $table['table']['columns']);
     $this->assertArrayHasKey('name', $table['table']['columns']['id']);
     $this->assertArrayHasKey('title', $table['table']['columns']['id']);
     $columnName = $table['table']['columns']['id']['name'];
     $columnTitle = $table['table']['columns']['id']['title'];
     $newTableName = uniqid();
     $this->client->updateTable(FUNCTIONAL_WRITER_ID, $tableId, $newTableName);
     $table = $this->client->getTable(FUNCTIONAL_WRITER_ID, $tableId);
     $this->assertEquals($newTableName, $table['table']['title']);
     $this->client->updateTable(FUNCTIONAL_WRITER_ID, $tableId, $tableName);
     $newColumnTitle = uniqid();
     $this->client->updateTableColumn(FUNCTIONAL_WRITER_ID, $tableId, $columnName, ['title' => $newColumnTitle]);
     $table = $this->client->getTable(FUNCTIONAL_WRITER_ID, $tableId);
     $this->assertEquals($newColumnTitle, $table['table']['columns']['id']['title']);
     $this->client->updateTableColumns(FUNCTIONAL_WRITER_ID, $tableId, [['name' => $columnName, 'title' => $columnTitle]]);
     $table = $this->client->getTable(FUNCTIONAL_WRITER_ID, $tableId);
     $this->assertEquals($columnTitle, $table['table']['columns']['id']['title']);
 }