diff options
author | Andreas Fischer <bantu@phpbb.com> | 2014-10-07 20:30:40 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2014-10-07 20:30:40 +0200 |
commit | 63bdd193e0da90dc12ff2b6523b255f832420d3b (patch) | |
tree | 0399b3fd74208ff8e17aec83052c17e8bcedaf8a /tests/test_framework | |
parent | c77d6f39f25690437bee29ca542b52e10600f0e0 (diff) | |
parent | d64a515476955add1baf2e6cacab2de58a39118a (diff) | |
download | forums-63bdd193e0da90dc12ff2b6523b255f832420d3b.tar forums-63bdd193e0da90dc12ff2b6523b255f832420d3b.tar.gz forums-63bdd193e0da90dc12ff2b6523b255f832420d3b.tar.bz2 forums-63bdd193e0da90dc12ff2b6523b255f832420d3b.tar.xz forums-63bdd193e0da90dc12ff2b6523b255f832420d3b.zip |
Merge pull request #3027 from nickvergessen/ticket/13137
[ticket/13137] Remove schema.json from repository
* nickvergessen/ticket/13137:
[ticket/13137] Create schema.json in build script
[ticket/13137] Improve output of create_schema_files.php
[ticket/13137] Add schema.json file to .gitignore
[ticket/13137] Generate the schema when the schema.json file is not available
[ticket/13137] Remove schema.json file
Diffstat (limited to 'tests/test_framework')
-rw-r--r-- | tests/test_framework/phpbb_database_test_case.php | 45 | ||||
-rw-r--r-- | tests/test_framework/phpbb_database_test_connection_manager.php | 19 |
2 files changed, 39 insertions, 25 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(); } diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 92e2080dba..5d643e43e2 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -356,8 +356,23 @@ class phpbb_database_test_connection_manager } // 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); + if (file_exists($directory . 'schema.json')) + { + $db_table_schema = file_get_contents($directory . 'schema.json'); + $db_table_schema = json_decode($db_table_schema, true); + } + else + { + global $phpbb_root_path, $phpEx, $table_prefix; + + $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx); + $classes = $finder->core_path('phpbb/db/migration/data/') + ->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); + $db_table_schema = $schema_generator->get_schema(); + } $db_tools = new \phpbb\db\tools($db, true); foreach ($db_table_schema as $table_name => $table_data) |