Skip to content

Commit 4f171ac

Browse files
committed
OXDEV-46 Clean up & small refactorings for readability
1 parent f314120 commit 4f171ac

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

library/UnitTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use modOXID;
2525
use modOxUtilsDate;
2626

27+
use oxDatabaseHelper;
2728
use OxidEsales\Eshop\Core\DatabaseProvider;
2829
use OxidEsales\EshopCommunity\Core\Database\Adapter\DatabaseInterface;
2930
use OxidEsales\EshopCommunity\Core\Database;
@@ -38,6 +39,7 @@
3839
use ReflectionClass;
3940
use Exception;
4041

42+
require_once TEST_LIBRARY_HELPERS_PATH . 'oxDatabaseHelper.php';
4143
require_once TEST_LIBRARY_HELPERS_PATH . 'modOxUtilsDate.php';
4244

4345
/**

library/helpers/oxDatabaseHelper.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/**
43
* This file is part of OXID eSales Testing Library.
54
*
@@ -81,6 +80,21 @@ public function existsView($tableName)
8180
return $tableNameView === $this->database->getOne($sql);
8281
}
8382

83+
/**
84+
* @param string $tableName The name of the table we want to assure to exist.
85+
*
86+
* @return bool Does the database table with the given name exists?
87+
*/
88+
public function existsTable($tableName)
89+
{
90+
$database = DatabaseProvider::getDb();
91+
$sql = "SELECT COUNT(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_NAME = '$tableName'";
92+
93+
$count = $database->getOne($sql);
94+
95+
return $count > 0;
96+
}
97+
8498
public function adjustTemplateBlocksOxModuleColumn()
8599
{
86100
$sql = "ALTER TABLE `oxtplblocks`

0 commit comments

Comments
 (0)