Skip to content

Commit

Permalink
fix baserproject#1962 BcDatabaseService::renameColumn のユニットテストを実装
Browse files Browse the repository at this point in the history
  • Loading branch information
Đỗ Văn Hùng authored and Đỗ Văn Hùng committed May 24, 2023
1 parent 0aead51 commit 97421f2
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 97421f2

Please sign in to comment.