diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-05-03 11:48:52 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-06-10 19:41:35 +0200 |
commit | 5bae2911a232648dcc355153180f9bb7ace64d83 (patch) | |
tree | 779205910b461e03425f2ef321b8668b08b4b377 /tests/test_framework/phpbb_database_test_case.php | |
parent | 709296e54ab678bc64f1dd4fc533224fd873058a (diff) | |
download | forums-5bae2911a232648dcc355153180f9bb7ace64d83.tar forums-5bae2911a232648dcc355153180f9bb7ace64d83.tar.gz forums-5bae2911a232648dcc355153180f9bb7ace64d83.tar.bz2 forums-5bae2911a232648dcc355153180f9bb7ace64d83.tar.xz forums-5bae2911a232648dcc355153180f9bb7ace64d83.zip |
[ticket/12483] Move schema files into tmp/ and only copy them when needed
PHPBB3-12483
Diffstat (limited to 'tests/test_framework/phpbb_database_test_case.php')
-rw-r--r-- | tests/test_framework/phpbb_database_test_case.php | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 157982ff3c..c704516968 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -54,40 +54,48 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test static public function setUpBeforeClass() { - $schema_md5 = md5(serialize(static::setup_extensions())); + $setup_extensions = static::setup_extensions(); + self::$schema_file = ''; + if (!empty($setup_extensions)) + { + $schema_md5 = md5(serialize($setup_extensions)); - self::$schema_file = __DIR__ . '/schemas/' . $schema_md5 . '.json'; - self::$phpbb_schema_copy = __DIR__ . '/schemas/schema_phpbb_copy.json'; - self::$install_schema_file = __DIR__ . '/../../../../../install/schemas/schema.json'; + 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'; - 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\extension\finder(new phpbb_testcase_extension_manager(static::setup_extensions()), new \phpbb\filesystem(), $phpbb_root_path); - $classes = $finder->core_path('phpbb/') - ->core_directory('db/migration/data') - ->extension_directory('migrations') - ->get_classes(); + $finder = new \phpbb\extension\finder(new phpbb_testcase_extension_manager(static::setup_extensions()), new \phpbb\filesystem(), $phpbb_root_path); + $classes = $finder->core_path('phpbb/') + ->core_directory('db/migration/data') + ->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(); + $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(); - $fp = fopen(self::$schema_file, 'wb'); - fwrite($fp, json_encode($schema_data)); - fclose($fp); - } + $fp = fopen(self::$schema_file, 'wb'); + fwrite($fp, json_encode($schema_data)); + fclose($fp); + } - copy(self::$install_schema_file, self::$phpbb_schema_copy); - copy(self::$schema_file, self::$install_schema_file); + copy(self::$install_schema_file, self::$phpbb_schema_copy); + copy(self::$schema_file, self::$install_schema_file); + } parent::setUpBeforeClass(); } static public function tearDownAfterClass() { - copy(self::$phpbb_schema_copy, self::$install_schema_file); + if (self::$schema_file !== '') + { + copy(self::$phpbb_schema_copy, self::$install_schema_file); + } parent::tearDownAfterClass(); } |