aboutsummaryrefslogtreecommitdiffstats
path: root/tests/extension/modules_test.php
blob: 9849ad2ca4d7628ed961746832cbe07465d77164 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

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
{
	protected $extension_manager;
	protected $finder;

	public function setUp()
	{
		global $phpbb_extension_manager;

		$this->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()
	{
		$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_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';
		$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);
	}
}