From 8cf2790d5577f7e2398d5017216d3c5540cb0eb0 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 24 Jul 2016 00:24:32 +0700 Subject: [ticket/14703] Add test for the case multiple parent module_langname found PHPBB3-14703 --- tests/dbal/fixtures/migrator_module.xml | 54 +++++++++++++++++++++++++++++++- tests/dbal/migrator_tool_module_test.php | 34 ++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) (limited to 'tests/dbal') diff --git a/tests/dbal/fixtures/migrator_module.xml b/tests/dbal/fixtures/migrator_module.xml index 32afe7e6f3..e172d7a145 100644 --- a/tests/dbal/fixtures/migrator_module.xml +++ b/tests/dbal/fixtures/migrator_module.xml @@ -20,7 +20,7 @@ acp 0 1 - 4 + 6 ACP_CAT @@ -38,5 +38,57 @@ test + + 3 + 1 + 1 + + acp + 1 + 4 + 5 + ACP_FORUM_BASED_PERMISSIONS + + + + + 4 + 1 + 1 + + acp + 0 + 7 + 12 + ACP_CAT_FORUMS + + + + + 5 + 1 + 1 + + acp + 4 + 8 + 11 + ACP_FORUM_BASED_PERMISSIONS + + + + + 6 + 1 + 1 + + acp + 5 + 9 + 10 + ACP_FORUM_BASED_PERMISSIONS_CHILD_1 + + + diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index 08c3e979b8..bf4ae0b1ee 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -118,6 +118,40 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $this->fail($e); } $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE')); + + // Test adding module when plural parent module_langname exists + // PHPBB3-14703 + // Adding fail + try + { + $this->tool->add('acp', 'ACP_FORUM_BASED_PERMISSIONS', array( + 'module_basename' => 'acp_new_permissions_module', + 'module_langname' => 'ACP_NEW_PERMISSIONS_MODULE', + 'module_mode' => 'test', + 'module_auth' => '', + )); + $this->fail('Exception not thrown'); + } + catch (Exception $e) {} + + // Test adding module when plural parent module_langname exists + // PHPBB3-14703 + // Adding success + try + { + $this->tool->add('acp', 'ACP_FORUM_BASED_PERMISSIONS', array( + 'module_basename' => 'acp_new_permissions_module', + 'module_langname' => 'ACP_NEW_PERMISSIONS_MODULE', + 'module_mode' => 'test', + 'module_auth' => '', + 'after' => 'ACP_FORUM_BASED_PERMISSIONS_CHILD_1', + )); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('acp', 'ACP_FORUM_BASED_PERMISSIONS', 'ACP_NEW_PERMISSIONS_MODULE')); } public function test_remove() -- cgit v1.2.3-65-gdbad From 557f85e7fc3dc299859e846a8f406f0e19aaf465 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 28 Aug 2016 21:36:49 +0700 Subject: [ticket/14703] Improve exception testing PHPBB3-14703 --- tests/dbal/migrator_tool_module_test.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/dbal') diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index bf4ae0b1ee..49dff8b929 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -132,7 +132,11 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case )); $this->fail('Exception not thrown'); } - catch (Exception $e) {} + catch (Exception $e) + { + $this->assertEquals('phpbb\db\migration\exception', get_class($e)); + $this->assertEquals('MODULE_EXIST_MULTIPLE', $e->getMessage()); + } // Test adding module when plural parent module_langname exists // PHPBB3-14703 -- cgit v1.2.3-65-gdbad