From aefca4b40f67bc4d0cc52c8f89705148237a5f05 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 21 Mar 2013 14:59:53 +0100 Subject: [PATCH 01/11] [ticket/11465] Use extension finder when adding extensions' acp modules The method acp_modules::get_module_infos() needs to use the extension finder whenever it is looking for a module's info file. While transitioning to the new extension system, only the initial search for all module info files was changed to the new system. Due to this it is not possible to add an extension's acp/mcp/ucp module manually in the ACP. This patch will always use the extension finder for the acp module's info files and therefore properly find the needed file. Additionally, the code has been cleaned up a little bit. PHPBB3-11465 --- phpBB/includes/acp/acp_modules.php | 74 +++++++++++------------------- 1 file changed, 26 insertions(+), 48 deletions(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 7c2ea86122..9cf6bf0214 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -544,81 +544,59 @@ class acp_modules */ function get_module_infos($module = '', $module_class = false, $use_all_available = false) { - global $phpbb_root_path, $phpEx; + global $phpbb_extension_manager, $phpbb_root_path, $phpEx; $module_class = ($module_class === false) ? $this->module_class : $module_class; $directory = $phpbb_root_path . 'includes/' . $module_class . '/info/'; $fileinfo = array(); - if (!$module) + $finder = $phpbb_extension_manager->get_finder(); + + $modules = $finder + ->extension_suffix('_module') + ->extension_directory("/$module_class") + ->core_path("includes/$module_class/info/") + ->core_prefix($module_class . '_') + ->get_classes(true, $use_all_available); + + foreach ($modules as $cur_module) { - global $phpbb_extension_manager; - - $finder = $phpbb_extension_manager->get_finder(); - - $modules = $finder - ->extension_suffix('_module') - ->extension_directory("/$module_class") - ->core_path("includes/$module_class/info/") - ->core_prefix($module_class . '_') - ->get_classes(true, $use_all_available); - - foreach ($modules as $module) + // Skip entries we do not need if we know the module we are + // looking for + if ($module && strpos($cur_module, $module) === false) { - $info_class = preg_replace('/_module$/', '_info', $module); - - // If the class does not exist it might be following the old - // format. phpbb_acp_info_acp_foo needs to be turned into - // acp_foo_info and the respective file has to be included - // manually because it does not support auto loading - if (!class_exists($info_class)) - { - $info_class = str_replace("phpbb_{$module_class}_info_", '', $module) . '_info'; - if (file_exists($directory . $info_class . '.' . $phpEx)) - { - include($directory . $info_class . '.' . $phpEx); - } - } - - if (class_exists($info_class)) - { - $info = new $info_class(); - $module_info = $info->module(); - - $main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $module; - - $fileinfo[$main_class] = $module_info; - } + continue; } - ksort($fileinfo); - } - else - { - $info_class = preg_replace('/_module$/', '_info', $module); + $info_class = preg_replace('/_module$/', '_info', $cur_module); + // If the class does not exist it might be following the old + // format. phpbb_acp_info_acp_foo needs to be turned into + // acp_foo_info and the respective file has to be included + // manually because it does not support auto loading if (!class_exists($info_class)) { - $info_class = $module . '_info'; - if (!class_exists($info_class) && file_exists($directory . $module . '.' . $phpEx)) + $info_class = str_replace("phpbb_{$module_class}_info_", '', $cur_module) . '_info'; + if (file_exists($directory . $info_class . '.' . $phpEx)) { - include($directory . $module . '.' . $phpEx); + include($directory . $info_class . '.' . $phpEx); } } - // Get module title tag if (class_exists($info_class)) { $info = new $info_class(); $module_info = $info->module(); - $main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $module; + $main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $cur_module; $fileinfo[$main_class] = $module_info; } } + ksort($fileinfo); + return $fileinfo; } From fadcee77b9ac652655f1dffb07979ac59b78b140 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 22 Mar 2013 10:12:39 +0100 Subject: [PATCH 02/11] [ticket/11465] Add unit tests for acp_modules::get_module_infos() The tests add 3 different modules. One acp module that should be found (acp/a_module), one acp module that should not be found (acp/fail_module), and one mcp module that should work again (mcp/a_module). The modules' info files had to be included as they were not auto-loaded for some reason. There are several test stages. First of, it is tested if the correct mcp and acp module is returned. Afterwards, the proper loading of specified modules is tested. One with an existing module and one with a not existing module. Finally, the test concludes with trying to get the module info of not existing ucp modules. Other classes like foobar would have also worked for that check but I decided to use the ucp type of class as that is the one type missing from the added test modules. PHPBB3-11465 --- tests/extension/ext/foo/acp/a_info.php | 16 ++++ tests/extension/ext/foo/acp/a_module.php | 5 ++ tests/extension/ext/foo/acp/fail_info.php | 16 ++++ tests/extension/ext/foo/acp/fail_module.php | 5 ++ tests/extension/ext/foo/mcp/a_info.php | 16 ++++ tests/extension/ext/foo/mcp/a_module.php | 5 ++ tests/extension/modules_test.php | 95 +++++++++++++++++++++ 7 files changed, 158 insertions(+) create mode 100644 tests/extension/ext/foo/acp/a_info.php create mode 100644 tests/extension/ext/foo/acp/a_module.php create mode 100644 tests/extension/ext/foo/acp/fail_info.php create mode 100644 tests/extension/ext/foo/acp/fail_module.php create mode 100644 tests/extension/ext/foo/mcp/a_info.php create mode 100644 tests/extension/ext/foo/mcp/a_module.php create mode 100644 tests/extension/modules_test.php diff --git a/tests/extension/ext/foo/acp/a_info.php b/tests/extension/ext/foo/acp/a_info.php new file mode 100644 index 0000000000..3e9bbffaca --- /dev/null +++ b/tests/extension/ext/foo/acp/a_info.php @@ -0,0 +1,16 @@ + 'phpbb_ext_foo_acp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ); + } +} diff --git a/tests/extension/ext/foo/acp/a_module.php b/tests/extension/ext/foo/acp/a_module.php new file mode 100644 index 0000000000..093b4b1ad7 --- /dev/null +++ b/tests/extension/ext/foo/acp/a_module.php @@ -0,0 +1,5 @@ + 'phpbb_ext_foo_acp_fail_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ); + } +} diff --git a/tests/extension/ext/foo/acp/fail_module.php b/tests/extension/ext/foo/acp/fail_module.php new file mode 100644 index 0000000000..dd16955418 --- /dev/null +++ b/tests/extension/ext/foo/acp/fail_module.php @@ -0,0 +1,5 @@ + 'phpbb_ext_foo_mcp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), + ), + ); + } +} diff --git a/tests/extension/ext/foo/mcp/a_module.php b/tests/extension/ext/foo/mcp/a_module.php new file mode 100644 index 0000000000..59d9f8cc6f --- /dev/null +++ b/tests/extension/ext/foo/mcp/a_module.php @@ -0,0 +1,5 @@ +extension_manager = new phpbb_mock_extension_manager( + dirname(__FILE__) . '/', + array( + 'foo' => array( + 'ext_name' => 'foo', + 'ext_active' => '1', + 'ext_path' => 'ext/foo/', + ), + 'bar' => array( + 'ext_name' => 'bar', + 'ext_active' => '1', + 'ext_path' => 'ext/bar/', + ), + )); + $phpbb_extension_manager = $this->extension_manager; + + $this->acp_modules = new acp_modules(); + } + + public function test_get_module_infos() + { + // the modules' info files needs to be included before the test for + // some reason ... + require_once dirname(__FILE__) . '/ext/foo/acp/a_info.php'; + require_once dirname(__FILE__) . '/ext/foo/mcp/a_info.php'; + require_once dirname(__FILE__) . '/ext/foo/acp/fail_info.php'; + + $this->acp_modules->module_class = 'acp'; + $acp_modules = $this->acp_modules->get_module_infos(); + $this->assertEquals(array( + 'phpbb_ext_foo_acp_a_module' => array( + 'filename' => 'phpbb_ext_foo_acp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ), + ), $acp_modules); + + $this->acp_modules->module_class = 'mcp'; + $acp_modules = $this->acp_modules->get_module_infos(); + $this->assertEquals(array( + 'phpbb_ext_foo_mcp_a_module' => array( + 'filename' => 'phpbb_ext_foo_mcp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), + ), + ), + ), $acp_modules); + + $this->acp_modules->module_class = 'mcp'; + $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module'); + $this->assertEquals(array( + 'phpbb_ext_foo_mcp_a_module' => array( + 'filename' => 'phpbb_ext_foo_mcp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), + ), + ), + ), $acp_modules); + + $this->acp_modules->module_class = 'mcp'; + $acp_modules = $this->acp_modules->get_module_infos('mcp_a_fail'); + $this->assertEquals(array(), $acp_modules); + + $this->acp_modules->module_class = 'ucp'; + $acp_modules = $this->acp_modules->get_module_infos(); + $this->assertEquals(array(), $acp_modules); + } +} From 11477a3f18078625d79205e4ab488a25ead7d15d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 22 Mar 2013 13:29:30 +0100 Subject: [PATCH 03/11] [ticket/11465] Move require_once() in unit test to the top of the file PHPBB3-11465 --- tests/extension/modules_test.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index 52ec3503e7..36f54fde32 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -7,7 +7,10 @@ * */ -require_once dirname(__FILE__) . './../../phpBB/includes/acp/acp_modules.php'; +require_once dirname(__FILE__) . '/ext/foo/acp/a_info.php'; +require_once dirname(__FILE__) . '/ext/foo/mcp/a_info.php'; +require_once dirname(__FILE__) . '/ext/foo/acp/fail_info.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php'; class phpbb_extension_modules_test extends phpbb_test_case { @@ -39,12 +42,6 @@ class phpbb_extension_modules_test extends phpbb_test_case public function test_get_module_infos() { - // the modules' info files needs to be included before the test for - // some reason ... - require_once dirname(__FILE__) . '/ext/foo/acp/a_info.php'; - require_once dirname(__FILE__) . '/ext/foo/mcp/a_info.php'; - require_once dirname(__FILE__) . '/ext/foo/acp/fail_info.php'; - $this->acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( From 6110380a35ec2bca1dc953e8dfd67b1131bb1e59 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 Apr 2013 13:07:25 +0200 Subject: [PATCH 04/11] [ticket/11465] Add phpBB module to test PHPBB3-11465 --- tests/extension/includes/acp/acp_foobar.php | 28 +++++++++++++++++++ .../includes/acp/info/acp_foobar.php | 26 +++++++++++++++++ tests/extension/modules_test.php | 8 ++++++ 3 files changed, 62 insertions(+) create mode 100644 tests/extension/includes/acp/acp_foobar.php create mode 100644 tests/extension/includes/acp/info/acp_foobar.php diff --git a/tests/extension/includes/acp/acp_foobar.php b/tests/extension/includes/acp/acp_foobar.php new file mode 100644 index 0000000000..c256a432e2 --- /dev/null +++ b/tests/extension/includes/acp/acp_foobar.php @@ -0,0 +1,28 @@ + 'acp_foobar', + 'title' => 'ACP Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), + ), + ); + } +} diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index 36f54fde32..9849ad2ca4 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -53,6 +53,14 @@ class phpbb_extension_modules_test extends phpbb_test_case 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), ), ), + 'acp_foobar' => array( + 'filename' => 'acp_foobar', + 'title' => 'ACP Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), + ), + ), ), $acp_modules); $this->acp_modules->module_class = 'mcp'; From 78bcc31a5d0cb01a4748f184fddd00a9b50f09f1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 Apr 2013 13:08:31 +0200 Subject: [PATCH 05/11] [ticket/11465] The info file does not have _info suffix PHPBB3-11465 --- phpBB/includes/acp/acp_modules.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 9cf6bf0214..62af12ad32 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -577,10 +577,11 @@ class acp_modules // manually because it does not support auto loading if (!class_exists($info_class)) { - $info_class = str_replace("phpbb_{$module_class}_info_", '', $cur_module) . '_info'; - if (file_exists($directory . $info_class . '.' . $phpEx)) + $info_class_file = str_replace("phpbb_{$module_class}_info_", '', $cur_module); + $info_class = $info_class_file . '_info'; + if (file_exists($directory . $info_class_file . '.' . $phpEx)) { - include($directory . $info_class . '.' . $phpEx); + include($directory . $info_class_file . '.' . $phpEx); } } From bc423f0d97e1cc531aa78505317e85604e57b88d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 Apr 2013 13:11:13 +0200 Subject: [PATCH 06/11] [ticket/11465] Correctly set the root path for the test PHPBB3-11465 --- tests/extension/modules_test.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index 9849ad2ca4..675fb1f4a0 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -42,6 +42,11 @@ class phpbb_extension_modules_test extends phpbb_test_case public function test_get_module_infos() { + global $phpbb_root_path; + + // Correctly set the root path for this test to this directory, so the classes can be found + $phpbb_root_path = dirname(__FILE__) . '/'; + $this->acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( From 7240759e34d4e67fbce632c03ae6818aad36a07c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 14 Apr 2013 17:25:45 +0200 Subject: [PATCH 07/11] [ticket/11465] Check if class exists before including info file PHPBB3-11465 --- phpBB/includes/acp/acp_modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 62af12ad32..ab416fb406 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -579,7 +579,7 @@ class acp_modules { $info_class_file = str_replace("phpbb_{$module_class}_info_", '', $cur_module); $info_class = $info_class_file . '_info'; - if (file_exists($directory . $info_class_file . '.' . $phpEx)) + if (!class_exists($info_class) && file_exists($directory . $info_class_file . '.' . $phpEx)) { include($directory . $info_class_file . '.' . $phpEx); } From 6a1fa3e0f40d1ce63ff8686b47bd131417d9fc04 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 10 May 2013 11:53:26 +0200 Subject: [PATCH 08/11] [ticket/11465] Add comments explaining the tests PHPBB3-11465 --- tests/extension/ext/foo/acp/fail_info.php | 5 ++++- tests/extension/ext/foo/acp/fail_module.php | 5 ++++- tests/extension/modules_test.php | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/extension/ext/foo/acp/fail_info.php b/tests/extension/ext/foo/acp/fail_info.php index 98b0eb9529..99aa09551e 100644 --- a/tests/extension/ext/foo/acp/fail_info.php +++ b/tests/extension/ext/foo/acp/fail_info.php @@ -1,5 +1,8 @@ acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( @@ -68,6 +69,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), ), $acp_modules); + // Find mcp module info files $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( @@ -81,6 +83,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), ), $acp_modules); + // Find a specific module info file (mcp_a_module) $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module'); $this->assertEquals(array( @@ -94,10 +97,12 @@ class phpbb_extension_modules_test extends phpbb_test_case ), ), $acp_modules); + // The mcp module info file we're looking for shouldn't exist $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos('mcp_a_fail'); $this->assertEquals(array(), $acp_modules); + // As there are no ucp modules we shouldn't find any $this->acp_modules->module_class = 'ucp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array(), $acp_modules); From 7327f9326f739f9b602fd8896e8a4731caa93ee8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 12 May 2013 16:49:49 +0200 Subject: [PATCH 09/11] [ticket/11465] Add tests for optional arguments of get_module_infos() The possibilities of the first argument have already been covered previously. The second argument will be covered with an entry that should exist, an incorrect entry, and the default false entry that should use the previously set module class. Unfortunately, the third argument doesn't have an effect in the tests, as the mocked extension manager will not properly handle enabled/disabled extensions. PHPBB3-11465 --- tests/extension/modules_test.php | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index f0acd6f2eb..d24a3ec52f 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -97,6 +97,20 @@ class phpbb_extension_modules_test extends phpbb_test_case ), ), $acp_modules); + // Find a specific module info file (mcp_a_module) with passing the module_class + $this->acp_modules->module_class = ''; + $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module', 'mcp'); + $this->assertEquals(array( + 'phpbb_ext_foo_mcp_a_module' => array( + 'filename' => 'phpbb_ext_foo_mcp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), + ), + ), + ), $acp_modules); + // The mcp module info file we're looking for shouldn't exist $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos('mcp_a_fail'); @@ -106,5 +120,51 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = 'ucp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array(), $acp_modules); + + // Get module info of specified extension module + $this->acp_modules->module_class = 'acp'; + $acp_modules = $this->acp_modules->get_module_infos('phpbb_ext_foo_acp_a_module'); + $this->assertEquals(array( + 'phpbb_ext_foo_acp_a_module' => array ( + 'filename' => 'phpbb_ext_foo_acp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array ( + 'config' => array ('title' => 'Config', 'auth' => '', 'cat' => array ('ACP_MODS')), + ), + ), + ), $acp_modules); + + // No specific module and module class set to an incorrect name + $acp_modules = $this->acp_modules->get_module_infos('', 'wcp', true); + $this->assertEquals(array(), $acp_modules); + + // No specific module, no module_class set in the function parameter, and an incorrect module class + $this->acp_modules->module_class = 'wcp'; + $acp_modules = $this->acp_modules->get_module_infos(); + $this->assertEquals(array(), $acp_modules); + + // No specific module, module class set to false (will default to the above acp) + // Setting $use_all_available will have no effect here as the ext manager is just mocked + $this->acp_modules->module_class = 'acp'; + $acp_modules = $this->acp_modules->get_module_infos('', false, true); + $this->assertEquals(array( + 'phpbb_ext_foo_acp_a_module' => array( + 'filename' => 'phpbb_ext_foo_acp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ), + 'acp_foobar' => array( + 'filename' => 'acp_foobar', + 'title' => 'ACP Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), + ), + ), + ), $acp_modules); } } From f90ed6c3cb9e1b8baeb352a07b81608fa7c067b5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 12 May 2013 22:21:16 +0200 Subject: [PATCH 10/11] [ticket/11465] Add disabled ext to allow proper testing of get_module_infos() This will now also enable us to test the $use_all_available parameter of get_module_infos(), which will not only return the module infos for enabled extensions but also those from disabled extensions. PHPBB3-11465 --- tests/extension/ext/barfoo/acp/a_info.php | 16 ++++++++++++++ tests/extension/ext/barfoo/acp/a_module.php | 5 +++++ tests/extension/ext/barfoo/ext.php | 5 +++++ tests/extension/manager_test.php | 2 +- tests/extension/modules_test.php | 24 ++++++++++++++++++++- 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tests/extension/ext/barfoo/acp/a_info.php create mode 100644 tests/extension/ext/barfoo/acp/a_module.php create mode 100644 tests/extension/ext/barfoo/ext.php diff --git a/tests/extension/ext/barfoo/acp/a_info.php b/tests/extension/ext/barfoo/acp/a_info.php new file mode 100644 index 0000000000..cd7e4e574b --- /dev/null +++ b/tests/extension/ext/barfoo/acp/a_info.php @@ -0,0 +1,16 @@ + 'phpbb_ext_barfoo_acp_a_module', + 'title' => 'Barfoo', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ); + } +} diff --git a/tests/extension/ext/barfoo/acp/a_module.php b/tests/extension/ext/barfoo/acp/a_module.php new file mode 100644 index 0000000000..5bedb49645 --- /dev/null +++ b/tests/extension/ext/barfoo/acp/a_module.php @@ -0,0 +1,5 @@ +assertEquals(array('bar', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_available())); + $this->assertEquals(array('bar', 'barfoo', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_available())); } public function test_enabled() diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index d24a3ec52f..fe71747c5d 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -10,6 +10,7 @@ require_once dirname(__FILE__) . '/ext/foo/acp/a_info.php'; require_once dirname(__FILE__) . '/ext/foo/mcp/a_info.php'; require_once dirname(__FILE__) . '/ext/foo/acp/fail_info.php'; +require_once dirname(__FILE__) . '/ext/barfoo/acp/a_info.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php'; class phpbb_extension_modules_test extends phpbb_test_case @@ -145,7 +146,7 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->assertEquals(array(), $acp_modules); // No specific module, module class set to false (will default to the above acp) - // Setting $use_all_available will have no effect here as the ext manager is just mocked + // Setting $use_all_available will cause get_module_infos() to also load not enabled extensions (barfoo) $this->acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos('', false, true); $this->assertEquals(array( @@ -165,6 +166,27 @@ class phpbb_extension_modules_test extends phpbb_test_case 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), ), ), + 'phpbb_ext_barfoo_acp_a_module' => array( + 'filename' => 'phpbb_ext_barfoo_acp_a_module', + 'title' => 'Barfoo', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ) + ), $acp_modules); + + // Specific module set to disabled extension + $acp_modules = $this->acp_modules->get_module_infos('phpbb_ext_barfoo_acp_a_module', 'acp', true); + $this->assertEquals(array( + 'phpbb_ext_barfoo_acp_a_module' => array( + 'filename' => 'phpbb_ext_barfoo_acp_a_module', + 'title' => 'Barfoo', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ) ), $acp_modules); } } From bd6cebfe3882d5df810eb1725a10cd64f5473240 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 12 May 2013 22:44:59 +0200 Subject: [PATCH 11/11] [ticket/11465] Increase count of disabled extensions to 5 in functional test The ACP function test checks the amount of disabled extensions. Due to the added disabled extension for the tests of the acp_modules method get_module_infos(), this needed to be increased from 4 to 5. PHPBB3-11465 --- tests/functional/extension_acp_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 1879cbd62c..1b406e5042 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -112,7 +112,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); $this->assertCount(1, $crawler->filter('.ext_enabled')); - $this->assertCount(4, $crawler->filter('.ext_disabled')); + $this->assertCount(5, $crawler->filter('.ext_disabled')); $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); $this->assertContainsLang('PURGE', $crawler->filter('.ext_enabled')->eq(0)->text());