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); + } +}