diff options
Diffstat (limited to 'tests/test_framework')
3 files changed, 31 insertions, 14 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); + } + } } /** diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d6eb4a632f..c0e58d1104 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -893,9 +893,9 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request * @param string $expected Lang var of expected message after posting - * @return array|null post_id, topic_id if message is 'POST_STORED' + * @return array|null post_id, topic_id if message is empty */ - public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') + public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = '') { $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; @@ -919,9 +919,9 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request * @param string $expected Lang var of expected message after posting - * @return array|null post_id, topic_id if message is 'POST_STORED' + * @return array|null post_id, topic_id if message is empty */ - public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') + public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = '') { $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; @@ -941,9 +941,9 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $posting_contains * @param array $form_data * @param string $expected Lang var of expected message after posting - * @return array|null post_id, topic_id if message is 'POST_STORED' + * @return array|null post_id, topic_id if message is empty */ - protected function submit_post($posting_url, $posting_contains, $form_data, $expected = 'POST_STORED') + protected function submit_post($posting_url, $posting_contains, $form_data, $expected = '') { $this->add_lang('posting'); @@ -989,13 +989,13 @@ class phpbb_functional_test_case extends phpbb_test_case // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) // Instead, I send it as a request with the submit button "post" set to true. $crawler = self::request('POST', $posting_url, $form_data); - $this->assertContainsLang($expected, $crawler->filter('html')->text()); - if ($expected !== 'POST_STORED') + if ($expected !== '') { - return; + $this->assertContainsLang($expected, $crawler->filter('html')->text()); + return null; } - $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); + $url = $crawler->selectLink($form_data['subject'])->link()->getUri(); return array( 'topic_id' => $this->get_parameter_from_link($url, 't'), |