aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal/migrator_tool_module_test.php
diff options
context:
space:
mode:
authorTristan Darricau <github@nicofuma.fr>2016-10-24 22:24:26 +0200
committerTristan Darricau <github@nicofuma.fr>2016-10-24 22:24:26 +0200
commitb13910ee45fc5c2985d00b2a8166489b2fc58bec (patch)
tree6fe77e3bbdd90b7178af5aba2471f8a0341d0e0a /tests/dbal/migrator_tool_module_test.php
parent52b1a9d4fa877bc6633ec53c905bd4dfaddbbf8d (diff)
parent163292bc1188efdd623a1270a1aedf7e9b281801 (diff)
downloadforums-b13910ee45fc5c2985d00b2a8166489b2fc58bec.tar
forums-b13910ee45fc5c2985d00b2a8166489b2fc58bec.tar.gz
forums-b13910ee45fc5c2985d00b2a8166489b2fc58bec.tar.bz2
forums-b13910ee45fc5c2985d00b2a8166489b2fc58bec.tar.xz
forums-b13910ee45fc5c2985d00b2a8166489b2fc58bec.zip
Merge branch '3.1.x' into 3.2.x
* 3.1.x: [ticket/14831] Optimize code construction [ticket/14831] Add more tests against UCP modules [ticket/14831] Add more tests, better name for $e placeholder [ticket/14831] Do not throw exception on the module existence checking [ticket/14831] Fix module migrator tool
Diffstat (limited to 'tests/dbal/migrator_tool_module_test.php')
-rw-r--r--tests/dbal/migrator_tool_module_test.php120
1 files changed, 115 insertions, 5 deletions
diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php
index 1744b7e92d..29b21166b6 100644
--- a/tests/dbal/migrator_tool_module_test.php
+++ b/tests/dbal/migrator_tool_module_test.php
@@ -45,10 +45,10 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$this->tool = new \phpbb\db\migration\tool\module($this->db, $this->cache, $this->user, $module_manager, $phpbb_root_path, $phpEx, 'phpbb_modules');
}
- public function exists_data()
+ public function exists_data_acp()
{
return array(
- // Test the category
+ // Test the existing category
array(
'',
'ACP_CAT',
@@ -60,7 +60,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
true,
),
- // Test the module
+ // Test the existing module
array(
'',
'ACP_MODULE',
@@ -76,17 +76,88 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
'ACP_MODULE',
true,
),
+
+ // Test for non-existant modules
+ array(
+ '',
+ 'ACP_NON_EXISTANT_CAT',
+ false,
+ ),
+ array(
+ 'ACP_CAT',
+ 'ACP_NON_EXISTANT_MODULE',
+ false,
+ ),
);
}
/**
- * @dataProvider exists_data
+ * @dataProvider exists_data_acp
*/
- public function test_exists($parent, $module, $expected)
+ public function test_exists_acp($parent, $module, $expected)
{
$this->assertEquals($expected, $this->tool->exists('acp', $parent, $module));
}
+ public function exists_data_ucp()
+ {
+ return array(
+ // Test the existing category
+ array(
+ '',
+ 'UCP_MAIN_CAT',
+ true,
+ ),
+ array(
+ 0,
+ 'UCP_MAIN_CAT',
+ true,
+ ),
+
+ // Test the existing module
+ array(
+ '',
+ 'UCP_SUBCATEGORY',
+ false,
+ ),
+ array(
+ false,
+ 'UCP_SUBCATEGORY',
+ true,
+ ),
+ array(
+ 'UCP_MAIN_CAT',
+ 'UCP_SUBCATEGORY',
+ true,
+ ),
+ array(
+ 'UCP_SUBCATEGORY',
+ 'UCP_MODULE',
+ true,
+ ),
+
+ // Test for non-existant modules
+ array(
+ '',
+ 'UCP_NON_EXISTANT_CAT',
+ false,
+ ),
+ array(
+ 'UCP_MAIN_CAT',
+ 'UCP_NON_EXISTANT_MODULE',
+ false,
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider exists_data_ucp
+ */
+ public function test_exists_ucp($parent, $module, $expected)
+ {
+ $this->assertEquals($expected, $this->tool->exists('ucp', $parent, $module));
+ }
+
public function test_add()
{
try
@@ -159,6 +230,45 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$this->fail($e);
}
$this->assertEquals(true, $this->tool->exists('acp', 'ACP_FORUM_BASED_PERMISSIONS', 'ACP_NEW_PERMISSIONS_MODULE'));
+
+ // Test adding UCP modules
+ // Test adding new UCP category
+ try
+ {
+ $this->tool->add('ucp', 0, 'UCP_NEW_CAT');
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('ucp', 0, 'UCP_NEW_CAT'));
+
+ // Test adding new UCP subcategory
+ try
+ {
+ $this->tool->add('ucp', 'UCP_NEW_CAT', 'UCP_NEW_SUBCAT');
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_SUBCAT'));
+
+ // Test adding new UCP module
+ try
+ {
+ $this->tool->add('ucp', 'UCP_NEW_SUBCAT', array(
+ 'module_basename' => 'ucp_new_module',
+ 'module_langname' => 'UCP_NEW_MODULE',
+ 'module_mode' => 'ucp_test',
+ 'module_auth' => '',
+ ));
+ }
+ catch (Exception $e)
+ {
+ $this->fail($e);
+ }
+ $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_SUBCAT', 'UCP_NEW_MODULE'));
}
public function test_remove()