aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_framework/phpbb_database_test_case.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_framework/phpbb_database_test_case.php')
-rw-r--r--tests/test_framework/phpbb_database_test_case.php36
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index 967387fd55..72bce2e38a 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -13,6 +13,8 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
protected $test_case_helpers;
+ protected $fixture_xml_data;
+
public function __construct($name = NULL, array $data = array(), $dataName = '')
{
parent::__construct($name, $data, $dataName);
@@ -28,6 +30,20 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
);
}
+ protected function setUp()
+ {
+ parent::setUp();
+
+ // Resynchronise tables if a fixture was loaded
+ if (isset($this->fixture_xml_data))
+ {
+ $config = $this->get_database_config();
+ $manager = $this->create_connection_manager($config);
+ $manager->connect();
+ $manager->post_setup_synchronisation($this->fixture_xml_data);
+ }
+ }
+
public function createXMLDataSet($path)
{
$db_config = $this->get_database_config();
@@ -47,7 +63,9 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
$path = $meta_data['uri'];
}
- return parent::createXMLDataSet($path);
+ $this->fixture_xml_data = parent::createXMLDataSet($path);
+
+ return $this->fixture_xml_data;
}
public function get_test_case_helpers()
@@ -139,4 +157,20 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
return $matches[1] . strtoupper($matches[2]) . $matches[3];
}
+
+ public function assert_array_content_equals($one, $two)
+ {
+ // http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
+ // but one array_diff is not enough!
+ if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one)))
+ {
+ // get a nice error message
+ $this->assertEquals($one, $two);
+ }
+ else
+ {
+ // increase assertion count
+ $this->assertTrue(true);
+ }
+ }
}