diff options
author | Tristan Darricau <github@nicofuma.fr> | 2014-10-10 15:55:03 +0200 |
---|---|---|
committer | Tristan Darricau <github@nicofuma.fr> | 2014-10-10 15:55:03 +0200 |
commit | 29b54d12ccece3ad0120089c17b0886e3b77f3d1 (patch) | |
tree | a710ba3e5e5f5a3b3e9b9fb23a0cee90f0e85a8d | |
parent | 5b186c936d6d6d67b8b0551a990522fdc68e2a4c (diff) | |
parent | 1a04d15d4d481f681cdfc65f3af7a42073b40e84 (diff) | |
download | forums-29b54d12ccece3ad0120089c17b0886e3b77f3d1.tar forums-29b54d12ccece3ad0120089c17b0886e3b77f3d1.tar.gz forums-29b54d12ccece3ad0120089c17b0886e3b77f3d1.tar.bz2 forums-29b54d12ccece3ad0120089c17b0886e3b77f3d1.tar.xz forums-29b54d12ccece3ad0120089c17b0886e3b77f3d1.zip |
Merge pull request #3029 from nickvergessen/ticket/13161
Ticket/13161 PHP Warnings issued from phpbb database test case
* nickvergessen/ticket/13161:
[ticket/13161] Check whether the schema exists, before deleting it
[ticket/13161] Avoid problems when running tests with different migrations
-rw-r--r-- | tests/test_framework/phpbb_database_test_case.php | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 26989fa345..fc1a3632f4 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -54,37 +54,31 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test static public function setUpBeforeClass() { + global $phpbb_root_path, $phpEx; + $setup_extensions = static::setup_extensions(); - $schema_md5 = md5(serialize($setup_extensions)); - self::$schema_file = __DIR__ . '/../tmp/' . $schema_md5 . '.json'; + $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx); + $finder->core_path('phpbb/db/migration/data/'); + if (!empty($setup_extensions)) + { + $finder->set_extensions($setup_extensions) + ->extension_directory('/migrations'); + } + $classes = $finder->get_classes(); + + $schema_sha1 = sha1(serialize($classes)); + self::$schema_file = __DIR__ . '/../tmp/' . $schema_sha1 . '.json'; self::$install_schema_file = __DIR__ . '/../../phpBB/install/schemas/schema.json'; if (!file_exists(self::$schema_file)) { - global $phpbb_root_path, $phpEx, $table_prefix; - $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx); - - if (!empty($setup_extensions)) - { - $classes = $finder->core_path('phpbb/db/migration/data/') - ->set_extensions($setup_extensions) - ->extension_directory('/migrations') - ->get_classes(); - - } - else - { - $classes = $finder->core_path('phpbb/db/migration/data/') - ->get_classes(); - } + global $table_prefix; $db = new \phpbb\db\driver\sqlite(); $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix); - $schema_data = $schema_generator->get_schema(); - - file_put_contents(self::$schema_file, json_encode($schema_data)); + file_put_contents(self::$schema_file, json_encode($schema_generator->get_schema())); } copy(self::$schema_file, self::$install_schema_file); @@ -94,7 +88,11 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test static public function tearDownAfterClass() { - unlink(self::$install_schema_file); + if (file_exists(self::$install_schema_file)) + { + unlink(self::$install_schema_file); + } + parent::tearDownAfterClass(); } |