diff --git a/Algorithm/Graph/DependencyResolver.php b/Algorithm/Graph/DependencyResolver.php new file mode 100644 index 000000000..5df540d32 --- /dev/null +++ b/Algorithm/Graph/DependencyResolver.php @@ -0,0 +1,84 @@ + $dependency) { + self::dependencyResolve($table, $graph, $resolved, $unresolved); + } + + return !empty($unresolved) ? null : $resolved; + } + + /** + * Algorithm to resolve dependencies + * + * @param int|string $item Item id + * @param array $items All items + * + * @return void + * + * @since 1.0.0 + */ + private static function dependencyResolve($item, array $items, array &$resolved, array &$unresolved) : void + { + $unresolved[] = $item; + + if (!isset($items[$item])) { + return; + } + + foreach ($items[$item] as $dependency) { + if (!\in_array($dependency, $unresolved)) { + $unresolved[] = $dependency; + self::dependencyResolve($dependency, $items, $resolved, $unresolved); + } else { + continue; // circular dependency + } + } + + if (!\in_array($item, $resolved)) { + $resolved[] = $item; + } + + foreach ($unresolved as $key => $unres) { + if ($unres === $item) { + unset($unresolved[$key]); + } + } + } +} diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index 46e489435..9d2ba52fc 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -48,14 +48,12 @@ abstract class InstallerAbstract public static function registerInDatabase(DatabasePool $dbPool, ModuleInfo $info) : void { $queryModule = new Builder($dbPool->get('insert')); - $queryModule->prefix($dbPool->get('insert')->prefix); $queryModule->insert('module_id', 'module_theme', 'module_path', 'module_active', 'module_version') ->into('module') ->values($info->getInternalName(), 'Default', $info->getDirectory(), 0, $info->getVersion()) ->execute(); $queryLoad = new Builder($dbPool->get('insert')); - $queryLoad->prefix($dbPool->get('insert')->prefix); $queryLoad->insert('module_load_pid', 'module_load_type', 'module_load_from', 'module_load_for', 'module_load_file') ->into('module_load'); diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 9a0c8fe96..5af46c4dc 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -165,7 +165,6 @@ final class ModuleManager $uriHash = $request->getHash(); $query = new Builder($this->app->dbPool->get('select')); - $query->prefix($this->app->dbPool->get('select')->prefix); $sth = $query->select('module_load.module_load_type', 'module_load.*') ->from('module_load') ->innerJoin('module')->on('module_load.module_load_from', '=', 'module.module_id')->orOn('module_load.module_load_for', '=', 'module.module_id') @@ -192,7 +191,6 @@ final class ModuleManager { if (empty($this->active) || !$useCache) { $query = new Builder($this->app->dbPool->get('select')); - $query->prefix($this->app->dbPool->get('select')->prefix); $sth = $query->select('module.module_path') ->from('module') ->where('module.module_active', '=', 1) @@ -310,7 +308,6 @@ final class ModuleManager { if (empty($this->installed) || !$useCache) { $query = new Builder($this->app->dbPool->get('select')); - $query->prefix($this->app->dbPool->get('select')->prefix); $sth = $query->select('module.module_path') ->from('module') ->execute(); diff --git a/Module/StatusAbstract.php b/Module/StatusAbstract.php index 2db5a27a6..900b34851 100644 --- a/Module/StatusAbstract.php +++ b/Module/StatusAbstract.php @@ -76,7 +76,6 @@ abstract class StatusAbstract public static function activateInDatabase(DatabasePool $dbPool, ModuleInfo $info) : void { $query = new Builder($dbPool->get('update')); - $query->prefix($dbPool->get('update')->prefix); $query->update('module') ->sets('module.module_active', 1) ->where('module.module_id', '=', $info->getInternalName()) @@ -130,7 +129,6 @@ abstract class StatusAbstract public static function deactivateInDatabase(DatabasePool $dbPool, ModuleInfo $info) : void { $query = new Builder($dbPool->get('update')); - $query->prefix($dbPool->get('update')->prefix); $query->update('module') ->sets('module.module_active', 0) ->where('module.module_id', '=', $info->getInternalName()) diff --git a/Module/UninstallerAbstract.php b/Module/UninstallerAbstract.php index 84cc78bc6..10665133f 100644 --- a/Module/UninstallerAbstract.php +++ b/Module/UninstallerAbstract.php @@ -74,7 +74,6 @@ abstract class UninstallerAbstract $definitions = \json_decode($content, true); $builder = new SchemaBuilder($dbPool->get('schema')); - $builder->prefix($dbPool->get('schema')->prefix); foreach ($definitions as $definition) { $builder->dropTable($definition['table'] ?? ''); @@ -96,14 +95,12 @@ abstract class UninstallerAbstract public static function unregisterFromDatabase(DatabasePool $dbPool, ModuleInfo $info) : void { $queryLoad = new Builder($dbPool->get('delete')); - $queryLoad->prefix($dbPool->get('delete')->prefix); $queryLoad->delete() ->from('module_load') ->where('module_load_from', '=', $info->getInternalName()) ->execute(); $queryModule = new Builder($dbPool->get('delete')); - $queryModule->prefix($dbPool->get('delete')->prefix); $queryModule->delete() ->from('module') ->where('module_id', '=', $info->getInternalName()) diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index b44e7cc09..fd057e8c0 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -28,7 +28,6 @@ $CONFIG = [ 'login' => 'root', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'insert' => [ @@ -38,7 +37,6 @@ $CONFIG = [ 'login' => 'root', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'select' => [ @@ -48,7 +46,6 @@ $CONFIG = [ 'login' => 'root', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'update' => [ @@ -58,7 +55,6 @@ $CONFIG = [ 'login' => 'root', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'delete' => [ @@ -68,7 +64,6 @@ $CONFIG = [ 'login' => 'root', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'schema' => [ @@ -78,7 +73,6 @@ $CONFIG = [ 'login' => 'root', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], ], @@ -90,7 +84,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'insert' => [ @@ -100,7 +93,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'select' => [ @@ -110,7 +102,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'update' => [ @@ -120,7 +111,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'delete' => [ @@ -130,7 +120,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'schema' => [ @@ -140,7 +129,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], ], @@ -148,37 +136,31 @@ $CONFIG = [ 'admin' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/test.sqlite', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'insert' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/test.sqlite', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'select' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/test.sqlite', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'update' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/test.sqlite', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'delete' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/test.sqlite', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'schema' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/test.sqlite', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], ], @@ -190,7 +172,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'insert' => [ @@ -200,7 +181,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'select' => [ @@ -210,7 +190,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'update' => [ @@ -220,7 +199,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'delete' => [ @@ -230,7 +208,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], 'schema' => [ @@ -240,7 +217,6 @@ $CONFIG = [ 'login' => 'postgres', /* db login name */ 'password' => 'root', /* db login password */ 'database' => 'oms', /* db name */ - 'prefix' => 'oms_', /* db table prefix */ 'weight' => 1000, /* db table prefix */ ], ], diff --git a/tests/DataStorage/Cache/Connection/FileCacheTest.php b/tests/DataStorage/Cache/Connection/FileCacheTest.php index 5fef6a227..d66c1b867 100644 --- a/tests/DataStorage/Cache/Connection/FileCacheTest.php +++ b/tests/DataStorage/Cache/Connection/FileCacheTest.php @@ -53,7 +53,6 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertEquals('', $this->cache->getPrefix()); self::assertEquals(CacheType::FILE, $this->cache->getType()); self::assertTrue(\is_dir(__DIR__ . '/Cache')); self::assertTrue($this->cache->flushAll()); diff --git a/tests/DataStorage/Cache/Connection/MemCachedTest.php b/tests/DataStorage/Cache/Connection/MemCachedTest.php index f06fe02e2..86e29fc89 100644 --- a/tests/DataStorage/Cache/Connection/MemCachedTest.php +++ b/tests/DataStorage/Cache/Connection/MemCachedTest.php @@ -51,7 +51,6 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertEquals('', $this->cache->getPrefix()); self::assertEquals(CacheType::MEMCACHED, $this->cache->getType()); self::assertTrue($this->cache->flushAll()); self::assertEquals(0, $this->cache->getThreshold()); diff --git a/tests/DataStorage/Cache/Connection/NullCacheTest.php b/tests/DataStorage/Cache/Connection/NullCacheTest.php index 41167b1f2..350e9d6ae 100644 --- a/tests/DataStorage/Cache/Connection/NullCacheTest.php +++ b/tests/DataStorage/Cache/Connection/NullCacheTest.php @@ -34,7 +34,6 @@ class NullCacheTest extends \PHPUnit\Framework\TestCase $cache = new NullCache(); $cache->connect([]); - self::assertEquals('', $cache->getPrefix()); self::assertEquals(CacheType::UNDEFINED, $cache->getType()); self::assertTrue($cache->add(1, 1)); diff --git a/tests/DataStorage/Cache/Connection/RedisCacheTest.php b/tests/DataStorage/Cache/Connection/RedisCacheTest.php index 42fcc5e75..39e9c6c87 100644 --- a/tests/DataStorage/Cache/Connection/RedisCacheTest.php +++ b/tests/DataStorage/Cache/Connection/RedisCacheTest.php @@ -51,7 +51,6 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertEquals('', $this->cache->getPrefix()); self::assertEquals(CacheType::REDIS, $this->cache->getType()); self::assertTrue($this->cache->flushAll()); self::assertEquals(0, $this->cache->getThreshold()); diff --git a/tests/DataStorage/Database/DataMapperAbstractTest.php b/tests/DataStorage/Database/DataMapperAbstractTest.php index 9df317ec1..e08983338 100644 --- a/tests/DataStorage/Database/DataMapperAbstractTest.php +++ b/tests/DataStorage/Database/DataMapperAbstractTest.php @@ -79,7 +79,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase ]; $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_base` ( + 'CREATE TABLE `test_base` ( `test_base_id` int(11) NOT NULL AUTO_INCREMENT, `test_base_string` varchar(254) NOT NULL, `test_base_int` int(11) NOT NULL, @@ -97,7 +97,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_belongs_to_one` ( + 'CREATE TABLE `test_belongs_to_one` ( `test_belongs_to_one_id` int(11) NOT NULL AUTO_INCREMENT, `test_belongs_to_one_string` varchar(254) NOT NULL, PRIMARY KEY (`test_belongs_to_one_id`) @@ -105,7 +105,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_owns_one` ( + 'CREATE TABLE `test_owns_one` ( `test_owns_one_id` int(11) NOT NULL AUTO_INCREMENT, `test_owns_one_string` varchar(254) NOT NULL, PRIMARY KEY (`test_owns_one_id`) @@ -113,7 +113,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_has_many_direct` ( + 'CREATE TABLE `test_has_many_direct` ( `test_has_many_direct_id` int(11) NOT NULL AUTO_INCREMENT, `test_has_many_direct_string` varchar(254) NOT NULL, `test_has_many_direct_to` int(11) NOT NULL, @@ -122,7 +122,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_has_many_rel` ( + 'CREATE TABLE `test_has_many_rel` ( `test_has_many_rel_id` int(11) NOT NULL AUTO_INCREMENT, `test_has_many_rel_string` varchar(254) NOT NULL, PRIMARY KEY (`test_has_many_rel_id`) @@ -130,7 +130,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_has_many_rel_relations` ( + 'CREATE TABLE `test_has_many_rel_relations` ( `test_has_many_rel_relations_id` int(11) NOT NULL AUTO_INCREMENT, `test_has_many_rel_relations_src` int(11) NOT NULL, `test_has_many_rel_relations_dest` int(11) NOT NULL, @@ -141,12 +141,12 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase protected function tearDown() : void { - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_base')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_belongs_to_one')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_owns_one')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_direct')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_rel')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_rel_relations')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_base')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_belongs_to_one')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_owns_one')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_direct')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_rel')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_rel_relations')->execute(); } /** diff --git a/tests/DataStorage/Database/Query/Grammar/GrammarTest.php b/tests/DataStorage/Database/Query/Grammar/GrammarTest.php index 95f225db5..19b0bebe8 100644 --- a/tests/DataStorage/Database/Query/Grammar/GrammarTest.php +++ b/tests/DataStorage/Database/Query/Grammar/GrammarTest.php @@ -31,17 +31,5 @@ class GrammarTest extends \PHPUnit\Framework\TestCase { $grammar = new Grammar(); self::assertEquals('Y-m-d H:i:s', $grammar->getDateFormat()); - self::assertEquals('', $grammar->getTablePrefix()); - } - - /** - * @testdox The grammar can define a default table prefix and return this value - * @group framework - */ - public function testPrefixInputOutput() : void - { - $grammar = new Grammar(); - $grammar->setTablePrefix('oms_'); - self::assertEquals('oms_', $grammar->getTablePrefix()); } } diff --git a/tests/DataStorage/Database/Schema/Grammar/GrammarTest.php b/tests/DataStorage/Database/Schema/Grammar/GrammarTest.php index c0c258aee..11a2a6a19 100644 --- a/tests/DataStorage/Database/Schema/Grammar/GrammarTest.php +++ b/tests/DataStorage/Database/Schema/Grammar/GrammarTest.php @@ -31,17 +31,5 @@ class GrammarTest extends \PHPUnit\Framework\TestCase { $grammar = new Grammar(); self::assertEquals('Y-m-d H:i:s', $grammar->getDateFormat()); - self::assertEquals('', $grammar->getTablePrefix()); - } - - /** - * @testdox The grammar can define a default table prefix and return this value - * @group framework - */ - public function testPrefixInputOutput() : void - { - $grammar = new Grammar(); - $grammar->setTablePrefix('oms_'); - self::assertEquals('oms_', $grammar->getTablePrefix()); } } diff --git a/tests/DataStorage/Database/Schema/Grammar/MysqlGrammarTest.php b/tests/DataStorage/Database/Schema/Grammar/MysqlGrammarTest.php index aa5e7a923..906a2e168 100644 --- a/tests/DataStorage/Database/Schema/Grammar/MysqlGrammarTest.php +++ b/tests/DataStorage/Database/Schema/Grammar/MysqlGrammarTest.php @@ -58,12 +58,12 @@ class MysqlGrammarTest extends \PHPUnit\Framework\TestCase } $table = new SchemaBuilder($this->con); - $tables = $table->prefix($this->con->prefix)->selectTables()->execute()->fetchAll(\PDO::FETCH_COLUMN); - self::assertContains($this->con->prefix . 'test', $tables); - self::assertContains($this->con->prefix . 'test_foreign', $tables); + $tables = $table->selectTables()->execute()->fetchAll(\PDO::FETCH_COLUMN); + self::assertContains('test', $tables); + self::assertContains('test_foreign', $tables); $field = new SchemaBuilder($this->con); - $fields = $field->prefix($this->con->prefix)->selectFields('test')->execute()->fetchAll(); + $fields = $field->selectFields('test')->execute()->fetchAll(); foreach ($definitions['test']['fields'] as $key => $field) { self::assertTrue( @@ -81,14 +81,14 @@ class MysqlGrammarTest extends \PHPUnit\Framework\TestCase public function testDelete() : void { $table = new SchemaBuilder($this->con); - $tables = $table->prefix($this->con->prefix)->selectTables()->execute()->fetchAll(\PDO::FETCH_COLUMN); + $tables = $table->selectTables()->execute()->fetchAll(\PDO::FETCH_COLUMN); $delete = new SchemaBuilder($this->con); - $delete->prefix($this->con->prefix)->dropTable('test')->execute(); - $delete->prefix($this->con->prefix)->dropTable('test_foreign')->execute(); + $delete->dropTable('test')->execute(); + $delete->dropTable('test_foreign')->execute(); - $tables = $table->prefix($this->con->prefix)->selectTables()->execute()->fetchAll(); - self::assertNotContains($this->con->prefix . 'test', $tables); - self::assertNotContains($this->con->prefix . 'test_foreign', $tables); + $tables = $table->selectTables()->execute()->fetchAll(); + self::assertNotContains('test', $tables); + self::assertNotContains('test_foreign', $tables); } } diff --git a/tests/DataStorage/Database/SchemaMapperTest.php b/tests/DataStorage/Database/SchemaMapperTest.php index 79b669401..bd0342421 100644 --- a/tests/DataStorage/Database/SchemaMapperTest.php +++ b/tests/DataStorage/Database/SchemaMapperTest.php @@ -25,7 +25,7 @@ class SchemaMapperTest extends \PHPUnit\Framework\TestCase protected function setUp() : void { $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_base` ( + 'CREATE TABLE `test_base` ( `test_base_id` int(11) NOT NULL AUTO_INCREMENT, `test_base_string` varchar(254) NOT NULL, `test_base_int` int(11) NOT NULL, @@ -43,7 +43,7 @@ class SchemaMapperTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_belongs_to_one` ( + 'CREATE TABLE `test_belongs_to_one` ( `test_belongs_to_one_id` int(11) NOT NULL AUTO_INCREMENT, `test_belongs_to_one_string` varchar(254) NOT NULL, PRIMARY KEY (`test_belongs_to_one_id`) @@ -53,8 +53,8 @@ class SchemaMapperTest extends \PHPUnit\Framework\TestCase protected function tearDown() : void { - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_base')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_belongs_to_one')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_base')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_belongs_to_one')->execute(); } /** @@ -66,8 +66,8 @@ class SchemaMapperTest extends \PHPUnit\Framework\TestCase { $schema = new SchemaMapper($GLOBALS['dbpool']->get()); - self::assertTrue(\in_array('oms_test_base', $schema->getTables())); - self::assertTrue(\in_array('oms_test_belongs_to_one', $schema->getTables())); + self::assertTrue(\in_array('test_base', $schema->getTables())); + self::assertTrue(\in_array('test_belongs_to_one', $schema->getTables())); } /** @@ -81,7 +81,7 @@ class SchemaMapperTest extends \PHPUnit\Framework\TestCase self::assertEquals( 12, - \count($schema->getFields('oms_test_base')) + \count($schema->getFields('test_base')) ); } } diff --git a/tests/Module/ModuleAbstractTest.php b/tests/Module/ModuleAbstractTest.php index c16d96915..848e139fe 100644 --- a/tests/Module/ModuleAbstractTest.php +++ b/tests/Module/ModuleAbstractTest.php @@ -213,7 +213,7 @@ class ModuleAbstractTest extends \PHPUnit\Framework\TestCase private function dbSetup() : void { $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_base` ( + 'CREATE TABLE `test_base` ( `test_base_id` int(11) NOT NULL AUTO_INCREMENT, `test_base_string` varchar(254) NOT NULL, `test_base_int` int(11) NOT NULL, @@ -231,7 +231,7 @@ class ModuleAbstractTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_belongs_to_one` ( + 'CREATE TABLE `test_belongs_to_one` ( `test_belongs_to_one_id` int(11) NOT NULL AUTO_INCREMENT, `test_belongs_to_one_string` varchar(254) NOT NULL, PRIMARY KEY (`test_belongs_to_one_id`) @@ -239,7 +239,7 @@ class ModuleAbstractTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_owns_one` ( + 'CREATE TABLE `test_owns_one` ( `test_owns_one_id` int(11) NOT NULL AUTO_INCREMENT, `test_owns_one_string` varchar(254) NOT NULL, PRIMARY KEY (`test_owns_one_id`) @@ -247,7 +247,7 @@ class ModuleAbstractTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_has_many_direct` ( + 'CREATE TABLE `test_has_many_direct` ( `test_has_many_direct_id` int(11) NOT NULL AUTO_INCREMENT, `test_has_many_direct_string` varchar(254) NOT NULL, `test_has_many_direct_to` int(11) NOT NULL, @@ -256,7 +256,7 @@ class ModuleAbstractTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_has_many_rel` ( + 'CREATE TABLE `test_has_many_rel` ( `test_has_many_rel_id` int(11) NOT NULL AUTO_INCREMENT, `test_has_many_rel_string` varchar(254) NOT NULL, PRIMARY KEY (`test_has_many_rel_id`) @@ -264,7 +264,7 @@ class ModuleAbstractTest extends \PHPUnit\Framework\TestCase )->execute(); $GLOBALS['dbpool']->get()->con->prepare( - 'CREATE TABLE `oms_test_has_many_rel_relations` ( + 'CREATE TABLE `test_has_many_rel_relations` ( `test_has_many_rel_relations_id` int(11) NOT NULL AUTO_INCREMENT, `test_has_many_rel_relations_src` int(11) NOT NULL, `test_has_many_rel_relations_dest` int(11) NOT NULL, @@ -275,12 +275,12 @@ class ModuleAbstractTest extends \PHPUnit\Framework\TestCase private function dbTeardown() : void { - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_base')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_belongs_to_one')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_owns_one')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_direct')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_rel')->execute(); - $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_rel_relations')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_base')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_belongs_to_one')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_owns_one')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_direct')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_rel')->execute(); + $GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_rel_relations')->execute(); } /**