aboutsummaryrefslogtreecommitdiffstats
path: root/tests/migrator
diff options
context:
space:
mode:
authorMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
committerMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
commit8ea437e30605e0f66b5220bf904a61d7c1d11ddd (patch)
treee0db2bb4a012d5b06a633160b19f62f4868ecd28 /tests/migrator
parent36bc1870f21fac04736a1049c1d5b8e127d729f4 (diff)
parent2fdd46b36431ae0f58bb2e78e42553168db9a0ff (diff)
downloadforums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.gz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.bz2
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.xz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.zip
Merge remote-tracking branch 'upstream/prep-release-3.2.9'
Diffstat (limited to 'tests/migrator')
-rw-r--r--tests/migrator/convert_timezones_test.php9
-rw-r--r--tests/migrator/get_callable_from_step_test.php136
-rw-r--r--tests/migrator/schema_generator_test.php5
3 files changed, 145 insertions, 5 deletions
diff --git a/tests/migrator/convert_timezones_test.php b/tests/migrator/convert_timezones_test.php
index 7501ed2ed0..f8d780da0c 100644
--- a/tests/migrator/convert_timezones_test.php
+++ b/tests/migrator/convert_timezones_test.php
@@ -18,7 +18,8 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
public function getDataSet()
{
$this->db = $this->new_dbal();
- $db_tools = new \phpbb\db\tools($this->db);
+ $factory = new \phpbb\db\tools\factory();
+ $db_tools = $factory->get($this->db);
// user_dst doesn't exist anymore, must re-add it to test this
$db_tools->sql_column_add('phpbb_users', 'user_dst', array('BOOL', 1));
@@ -55,11 +56,12 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
global $phpbb_root_path, $phpEx;
$this->db = $this->new_dbal();
+ $factory = new \phpbb\db\tools\factory();
$this->migration = new \phpbb\db\migration\data\v310\timezone(
new \phpbb\config\config(array()),
$this->db,
- new \phpbb\db\tools($this->db),
+ $factory->get($this->db),
$phpbb_root_path,
$phpEx,
'phpbb_'
@@ -90,7 +92,8 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
}
$this->db->sql_freeresult($result);
- $db_tools = new \phpbb\db\tools($this->db);
+ $factory = new \phpbb\db\tools\factory();
+ $db_tools = $factory->get($this->db);
// Remove the user_dst field again
$db_tools->sql_column_remove('phpbb_users', 'user_dst');
diff --git a/tests/migrator/get_callable_from_step_test.php b/tests/migrator/get_callable_from_step_test.php
new file mode 100644
index 0000000000..af636f5d21
--- /dev/null
+++ b/tests/migrator/get_callable_from_step_test.php
@@ -0,0 +1,136 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+class get_callable_from_step_test extends phpbb_database_test_case
+{
+ public function setUp()
+ {
+ global $phpbb_root_path, $php_ext, $table_prefix, $phpbb_log;
+
+ parent::setUp();
+
+ $phpbb_log = $this->getMockBuilder('\phpbb\log\log')->disableOriginalConstructor()->getMock();
+ $db = $this->new_dbal();
+ $factory = new \phpbb\db\tools\factory();
+ $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock();
+ $user = $this->getMockBuilder('\phpbb\user')->disableOriginalConstructor()->getMock();
+ $module_manager = new \phpbb\module\module_manager(
+ $this->getMockBuilder('\phpbb\cache\driver\dummy')->disableOriginalConstructor()->getMock(),
+ $db,
+ new phpbb_mock_extension_manager($phpbb_root_path),
+ 'phpbb_modules',
+ $phpbb_root_path,
+ $php_ext
+ );
+ $module_tools = new \phpbb\db\migration\tool\module($db, $cache_service, $user, $module_manager, $phpbb_root_path, $php_ext, 'phpbb_modules');
+ $this->migrator = new \phpbb\db\migrator(
+ new phpbb_mock_container_builder(),
+ new \phpbb\config\config(array()),
+ $db,
+ $factory->get($db),
+ 'phpbb_migrations',
+ $phpbb_root_path,
+ $php_ext,
+ $table_prefix,
+ array($module_tools),
+ new \phpbb\db\migration\helper()
+ );
+
+ if (!$module_tools->exists('acp', 0, 'new_module_langname'))
+ {
+ $module_tools->add('acp', 0, array(
+ 'module_basename' => 'new_module_basename',
+ 'module_langname' => 'new_module_langname',
+ 'module_mode' => 'settings',
+ 'module_auth' => '',
+ 'module_display' => true,
+ 'before' => false,
+ 'after' => false,
+ ));
+ $this->module_added = true;
+ }
+ }
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/../dbal/fixtures/migrator.xml');
+ }
+
+ public function get_callable_from_step_provider()
+ {
+ return array(
+ array(
+ array('if', array(
+ false,
+ array('permission.add', array('some_data')),
+ )),
+ true, // expects false
+ ),
+ array(
+ array('if', array(
+ array('module.exists', array(
+ 'mcp',
+ 'RANDOM_PARENT',
+ 'RANDOM_MODULE'
+ )),
+ array('permission.add', array('some_data')),
+ )),
+ true, // expects false
+ ),
+ array(
+ array('if', array(
+ array('module.exists', array(
+ 'acp',
+ 0,
+ 'new_module_langname'
+ )),
+ array('module.add', array(
+ 'acp',
+ 0,
+ 'module_basename' => 'new_module_basename2',
+ 'module_langname' => 'new_module_langname2',
+ 'module_mode' => 'settings',
+ 'module_auth' => '',
+ 'module_display' => true,
+ 'before' => false,
+ 'after' => false,
+ )),
+ )),
+ false, // expects false
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider get_callable_from_step_provider
+ */
+ public function test_get_callable_from_step($step, $expects_false)
+ {
+ if ($expects_false)
+ {
+ $this->assertFalse($this->call_get_callable_from_step($step));
+ }
+ else
+ {
+ $this->assertNotFalse($this->call_get_callable_from_step($step));
+ }
+ }
+
+ protected function call_get_callable_from_step($step)
+ {
+ $class = new ReflectionClass($this->migrator);
+ $method = $class->getMethod('get_callable_from_step');
+ $method->setAccessible(true);
+ return $method->invokeArgs($this->migrator, array($step));
+ }
+}
diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php
index 9adf518a5d..1996d207ea 100644
--- a/tests/migrator/schema_generator_test.php
+++ b/tests/migrator/schema_generator_test.php
@@ -29,8 +29,9 @@ class schema_generator_test extends phpbb_test_case
parent::setUp();
$this->config = new \phpbb\config\config(array());
- $this->db = new \phpbb\db\driver\sqlite();
- $this->db_tools = new \phpbb\db\tools($this->db);
+ $this->db = new \phpbb\db\driver\sqlite3();
+ $factory = new \phpbb\db\tools\factory();
+ $this->db_tools = $factory->get($this->db);
$this->table_prefix = 'phpbb_';
}