From 5e8054f04598c449799a594fcb96cfeb8abf925a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Jun 2013 13:24:55 +0200 Subject: [ticket/11601] Split post_setup_synchronisation logic from xml parsing PHPBB3-11601 --- .../phpbb_database_test_connection_manager.php | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'tests/test_framework') diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index bcd52b1794..30f1fa6589 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -480,12 +480,33 @@ class phpbb_database_test_connection_manager * @return null */ public function post_setup_synchronisation($xml_data_set) + { + $table_names = $xml_data_set->getTableNames(); + + $tables = array(); + foreach ($table_names as $table) + { + $tables[$table] = $xml_data_set->getTableMetaData($table)->getColumns(); + } + + $this->database_synchronisation($tables); + } + + /** + * Performs synchronisations on the database after a fixture has been loaded + * + * @param array $table_column_map Array of tables/columns to synchronise + * array(table1 => array(column1, column2)) + * + * @return null + */ + public function database_synchronisation($table_column_map) { $this->ensure_connected(__METHOD__); $queries = array(); - // Get escaped versions of the table names used in the fixture - $table_names = array_map(array($this->pdo, 'PDO::quote'), $xml_data_set->getTableNames()); + // Get escaped versions of the table names to synchronise + $table_names = array_map(array($this->pdo, 'PDO::quote'), array_keys($table_column_map)); switch ($this->config['dbms']) { @@ -542,7 +563,7 @@ class phpbb_database_test_connection_manager while ($row = $result->fetch(PDO::FETCH_ASSOC)) { // Get the columns used in the fixture for this table - $column_names = $xml_data_set->getTableMetaData($row['table_name'])->getColumns(); + $column_names = $table_column_map[$row['table_name']]; // Skip sequences that weren't specified in the fixture if (!in_array($row['column_name'], $column_names)) -- cgit v1.2.1 From 33bce3fac6c29787e121e5d000251353637dd422 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Jun 2013 13:26:17 +0200 Subject: [ticket/11601] Add protected method for database sync and call it PHPBB3-11601 --- tests/test_framework/phpbb_database_test_case.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/test_framework') diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index beddece470..28d3a716f0 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -62,6 +62,21 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test } } + /** + * Performs synchronisations for a given table/column set on the database + * + * @param array $table_column_map Information about the tables/columns to synchronise + * + * @return null + */ + protected function database_synchronisation($table_column_map) + { + $config = $this->get_database_config(); + $manager = $this->create_connection_manager($config); + $manager->connect(); + $manager->database_synchronisation($table_column_map); + } + public function createXMLDataSet($path) { $db_config = $this->get_database_config(); -- cgit v1.2.1