diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-10-07 14:53:03 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-10-07 14:55:08 +0200 |
commit | 4fe95d6870ab1700f104b16223791933c8e50ff9 (patch) | |
tree | dbbe016a8adc201a949ffeac74aff135931534b5 /tests/test_framework/phpbb_database_test_case.php | |
parent | 943f2e1a7ba9264dcf0ec4c2b0f4f8e89a07b5ce (diff) | |
download | forums-4fe95d6870ab1700f104b16223791933c8e50ff9.tar forums-4fe95d6870ab1700f104b16223791933c8e50ff9.tar.gz forums-4fe95d6870ab1700f104b16223791933c8e50ff9.tar.bz2 forums-4fe95d6870ab1700f104b16223791933c8e50ff9.tar.xz forums-4fe95d6870ab1700f104b16223791933c8e50ff9.zip |
[ticket/13137] Generate the schema when the schema.json file is not available
PHPBB3-13137
Diffstat (limited to 'tests/test_framework/phpbb_database_test_case.php')
-rw-r--r-- | tests/test_framework/phpbb_database_test_case.php | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 9dbb7150f1..26989fa345 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -55,47 +55,46 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test static public function setUpBeforeClass() { $setup_extensions = static::setup_extensions(); - self::$schema_file = ''; - if (!empty($setup_extensions)) - { - $schema_md5 = md5(serialize($setup_extensions)); - self::$schema_file = __DIR__ . '/../tmp/' . $schema_md5 . '.json'; - self::$phpbb_schema_copy = __DIR__ . '/../tmp/schema_phpbb_copy.json'; - self::$install_schema_file = __DIR__ . '/../../phpBB/install/schemas/schema.json'; + $schema_md5 = md5(serialize($setup_extensions)); + self::$schema_file = __DIR__ . '/../tmp/' . $schema_md5 . '.json'; + self::$install_schema_file = __DIR__ . '/../../phpBB/install/schemas/schema.json'; - if (!file_exists(self::$schema_file)) - { - global $phpbb_root_path, $phpEx, $table_prefix; + 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); - $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(); - $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(); + } + else + { - file_put_contents(self::$schema_file, json_encode($schema_data)); + $classes = $finder->core_path('phpbb/db/migration/data/') + ->get_classes(); } - copy(self::$install_schema_file, self::$phpbb_schema_copy); - copy(self::$schema_file, self::$install_schema_file); + $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)); } + copy(self::$schema_file, self::$install_schema_file); + parent::setUpBeforeClass(); } static public function tearDownAfterClass() { - if (self::$schema_file !== '') - { - copy(self::$phpbb_schema_copy, self::$install_schema_file); - unlink(self::$schema_file); - } - + unlink(self::$install_schema_file); parent::tearDownAfterClass(); } |