Skip to content

Commit

Permalink
fix #1962 BcDatabaseService::renameColumn のユニットテストを実装 (#2211)
Browse files Browse the repository at this point in the history
Co-authored-by: Đỗ Văn Hùng <HungDV2022>
  • Loading branch information
HungDV2022 committed May 30, 2023
1 parent 5533b9f commit b988f5d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions plugins/baser-core/src/Service/BcDatabaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ public function removeColumn(string $tableName, string $columnName)
* @param string $columnName
* @param string $newColumnName
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public function renameColumn(
string $tableName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,24 @@ public function test_removeColumn()
*/
public function test_renameColumn()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
// テーブル生成
$table = 'table_test_rename';
$columns = [
'new_column' => ['type' => 'text']
];
$this->BcDatabaseService->createTable($table, $columns);

// 対象メソッドを呼ぶ
$result = $this->BcDatabaseService->renameColumn($table, 'new_column', 'rename_column');

// 戻り値を確認
$this->assertTrue($result);
// カラムが変更されているか確認
$this->assertFalse($this->BcDatabaseService->columnExists($table, 'new_column'));
$this->assertTrue($this->BcDatabaseService->columnExists($table, 'rename_column'));

// テストテーブルを削除
$this->BcDatabaseService->dropTable($table);
}

/**
Expand Down

0 comments on commit b988f5d

Please sign in to comment.