Skip to content

Commit

Permalink
fix #1736 BcDatabaseService::tableExists のユニットテストを実装 (#1794)
Browse files Browse the repository at this point in the history
  • Loading branch information
mb-t-goto committed Feb 1, 2023
1 parent 70e5bd9 commit fcd6fb5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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 @@ -206,6 +206,9 @@ public function createTable(string $tableName, array $columns = [])
*
* @param string $tableName
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public function tableExists(string $tableName): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
namespace BaserCore\Test\TestCase\Service;

use BaserCore\Database\Schema\BcSchema;
use BaserCore\Service\BcDatabaseService;
use BaserCore\Service\BcDatabaseServiceInterface;
use BaserCore\Service\SiteConfigsServiceInterface;
Expand Down Expand Up @@ -715,4 +716,26 @@ public function test_migrate()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
}

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

// 対象メソッドを呼ぶ
$result = $this->BcDatabaseService->tableExists($table);
$this->assertTrue($result, 'テーブルが存在すること');

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

0 comments on commit fcd6fb5

Please sign in to comment.