Skip to content

Commit

Permalink
fix baserproject#1737 BcDatabaseService::dropTable のユニットテストを実装 (baser…
Browse files Browse the repository at this point in the history
…project#2004)

Co-authored-by: Nghiem <nguyennghiem1205@gmail.com>
  • Loading branch information
nghiem-mb and nghiemnv1205 committed Mar 13, 2023
1 parent c1a16bc commit 08c1b41
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/baser-core/src/Service/BcDatabaseService.php
Expand Up @@ -269,6 +269,7 @@ public function tableExists(string $tableName): bool
*
* @param string $tableName
* @return bool
* @unitTest
*/
public function dropTable(string $tableName)
{
Expand Down
Expand Up @@ -806,4 +806,27 @@ public function test_tableExist()
// テーブル削除
$this->BcDatabaseService->dropTable($table);
}

/**
* Test dropTable
*/
public function test_dropTable()
{
// テーブル生成
$table = 'table_test_exist';
$columns = [
'id' => ['type' => 'integer'],
'contents' => ['type' => 'text'],
];
$schema = new BcSchema($table, $columns);
$schema->create();

// 対象メソッドを呼ぶ
$result = $this->BcDatabaseService->dropTable($table);
$this->assertTrue($result, 'テーブル削除しました。');

// テーブル存在のチェック
$result = $this->BcDatabaseService->tableExists($table);
$this->assertFalse($result, 'テーブルが存在しないこと');
}
}

0 comments on commit 08c1b41

Please sign in to comment.