aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-05-12 16:49:49 +0200
committerMarc Alexander <admin@m-a-styles.de>2013-05-12 16:57:30 +0200
commit7327f9326f739f9b602fd8896e8a4731caa93ee8 (patch)
tree245f4ff3225fa686369978af198c12f1c4bddff3
parent6a1fa3e0f40d1ce63ff8686b47bd131417d9fc04 (diff)
downloadforums-7327f9326f739f9b602fd8896e8a4731caa93ee8.tar
forums-7327f9326f739f9b602fd8896e8a4731caa93ee8.tar.gz
forums-7327f9326f739f9b602fd8896e8a4731caa93ee8.tar.bz2
forums-7327f9326f739f9b602fd8896e8a4731caa93ee8.tar.xz
forums-7327f9326f739f9b602fd8896e8a4731caa93ee8.zip
[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
-rw-r--r--tests/extension/modules_test.php60
1 files changed, 60 insertions, 0 deletions
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);
}
}