aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_framework
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-03-28 23:12:54 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-03-29 11:03:43 +0100
commitba139297b5076881763b55d33fed90b48a051b6b (patch)
treeb5e83a38a5e327c167a645db4798722bd5cb573e /tests/test_framework
parent67737345f615178e924a2a0ecac58d9a75806b32 (diff)
downloadforums-ba139297b5076881763b55d33fed90b48a051b6b.tar
forums-ba139297b5076881763b55d33fed90b48a051b6b.tar.gz
forums-ba139297b5076881763b55d33fed90b48a051b6b.tar.bz2
forums-ba139297b5076881763b55d33fed90b48a051b6b.tar.xz
forums-ba139297b5076881763b55d33fed90b48a051b6b.zip
[ticket/11459] Correctly set up the database from schema in unit tests
PHPBB3-11459
Diffstat (limited to 'tests/test_framework')
-rw-r--r--tests/test_framework/phpbb_database_test_case.php2
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php23
2 files changed, 21 insertions, 4 deletions
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index 4c2e9ff600..aacdb1bef4 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -138,7 +138,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
if (!self::$already_connected)
{
- $manager->load_schema();
+ $manager->load_schema($this->new_dbal());
self::$already_connected = true;
}
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index af9bd22662..5d8dae4a30 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -169,12 +169,12 @@ class phpbb_database_test_connection_manager
/**
* Load the phpBB database schema into the database
*/
- public function load_schema()
+ public function load_schema($db)
{
$this->ensure_connected(__METHOD__);
$directory = dirname(__FILE__) . '/../../phpBB/install/schemas/';
- $this->load_schema_from_file($directory);
+ $this->load_schema_from_file($directory, $db);
}
/**
@@ -321,7 +321,7 @@ class phpbb_database_test_connection_manager
* Compile the correct schema filename (as per create_schema_files) and
* load it into the database.
*/
- protected function load_schema_from_file($directory)
+ protected function load_schema_from_file($directory, \phpbb\db\driver\driver $db)
{
$schema = $this->dbms['SCHEMA'];
@@ -351,6 +351,23 @@ class phpbb_database_test_connection_manager
{
$this->pdo->exec($query);
}
+
+ // Ok we have the db info go ahead and work on building the table
+ $db_table_schema = file_get_contents($directory . 'schema.json');
+ $db_table_schema = json_decode($db_table_schema, true);
+
+ $db_tools = new \phpbb\db\tools($db, true);
+ foreach ($db_table_schema as $table_name => $table_data)
+ {
+ $queries = $db_tools->sql_create_table(
+ $table_name,
+ $table_data
+ );
+ foreach ($queries as $query)
+ {
+ $this->pdo->exec($query);
+ }
+ }
}
/**