diff options
Diffstat (limited to 'tests/extension')
| -rw-r--r-- | tests/extension/ext/barfoo/composer.json | 2 | ||||
| -rw-r--r-- | tests/extension/ext/vendor/moo/composer.json | 2 | ||||
| -rw-r--r-- | tests/extension/ext/vendor2/bar/composer.json | 2 | ||||
| -rw-r--r-- | tests/extension/ext/vendor2/foo/acp/a_info.php | 2 | ||||
| -rw-r--r-- | tests/extension/ext/vendor2/foo/composer.json | 2 | ||||
| -rw-r--r-- | tests/extension/manager_test.php | 3 | ||||
| -rw-r--r-- | tests/extension/metadata_manager_test.php | 15 | ||||
| -rw-r--r-- | tests/extension/modules_test.php | 46 |
8 files changed, 58 insertions, 16 deletions
diff --git a/tests/extension/ext/barfoo/composer.json b/tests/extension/ext/barfoo/composer.json index 35d5d2a956..d88fd413c9 100644 --- a/tests/extension/ext/barfoo/composer.json +++ b/tests/extension/ext/barfoo/composer.json @@ -4,7 +4,7 @@ "description": "An example/sample extension to be used for testing purposes in phpBB Development.", "version": "1.0.0", "time": "2012-02-15 01:01:01", - "licence": "GNU GPL v2", + "license": "GNU GPL v2", "authors": [{ "name": "John Smith", "username": "JohnSmith27", diff --git a/tests/extension/ext/vendor/moo/composer.json b/tests/extension/ext/vendor/moo/composer.json index 901cb7f17a..b8fc544c01 100644 --- a/tests/extension/ext/vendor/moo/composer.json +++ b/tests/extension/ext/vendor/moo/composer.json @@ -4,7 +4,7 @@ "description": "An example/sample extension to be used for testing purposes in phpBB Development.", "version": "1.0.0", "time": "2012-02-15 01:01:01", - "licence": "GNU GPL v2", + "license": "GNU GPL v2", "authors": [{ "name": "John Smith", "username": "JohnSmith27", diff --git a/tests/extension/ext/vendor2/bar/composer.json b/tests/extension/ext/vendor2/bar/composer.json index 5d60ec031e..215e7d59db 100644 --- a/tests/extension/ext/vendor2/bar/composer.json +++ b/tests/extension/ext/vendor2/bar/composer.json @@ -4,7 +4,7 @@ "description": "An example/sample extension to be used for testing purposes in phpBB Development.", "version": "1.0.0", "time": "2012-02-15 01:01:01", - "licence": "GPL-2.0", + "license": "GPL-2.0", "authors": [{ "name": "John Smith", "email": "email@phpbb.com", diff --git a/tests/extension/ext/vendor2/foo/acp/a_info.php b/tests/extension/ext/vendor2/foo/acp/a_info.php index 27e67c1556..e1eaa340b7 100644 --- a/tests/extension/ext/vendor2/foo/acp/a_info.php +++ b/tests/extension/ext/vendor2/foo/acp/a_info.php @@ -11,7 +11,7 @@ class a_info 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( - 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + 'config' => array('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')), ), ); } diff --git a/tests/extension/ext/vendor2/foo/composer.json b/tests/extension/ext/vendor2/foo/composer.json index 8821d9d50e..7b2a80f5d3 100644 --- a/tests/extension/ext/vendor2/foo/composer.json +++ b/tests/extension/ext/vendor2/foo/composer.json @@ -4,7 +4,7 @@ "description": "An example/sample extension to be used for testing purposes in phpBB Development.", "version": "1.0.0", "time": "2012-02-15 01:01:01", - "licence": "GPL-2.0", + "license": "GPL-2.0", "authors": [{ "name": "John Smith", "email": "email@phpbb.com", diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index cc32a6af4e..789dc20d14 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -106,7 +106,8 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $phpbb_root_path, $php_ext, $table_prefix, - array() + array(), + new \phpbb\db\migration\helper() ); $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 592421f9e7..a3584be67b 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -62,7 +62,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->phpbb_root_path, 'php', $this->table_prefix, - array() + array(), + new \phpbb\db\migration\helper() ); $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); @@ -147,13 +148,13 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case try { - $manager->validate('licence'); + $manager->validate('license'); $this->fail('Exception not triggered'); } catch(\phpbb\extension\exception $e) { - $this->assertEquals((string) $e, 'Required meta field \'licence\' has not been set.'); + $this->assertEquals((string) $e, 'Required meta field \'license\' has not been set.'); } try @@ -207,7 +208,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $manager->set_metadata(array( 'name' => 'asdf', 'type' => 'asdf', - 'licence' => '', + 'license' => '', 'version' => '', )); @@ -235,13 +236,13 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case try { - $manager->validate('licence'); + $manager->validate('license'); $this->fail('Exception not triggered'); } catch(\phpbb\extension\exception $e) { - $this->assertEquals((string) $e, 'Meta field \'licence\' is invalid.'); + $this->assertEquals((string) $e, 'Meta field \'license\' is invalid.'); } try @@ -266,7 +267,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $manager->set_metadata(array( 'name' => 'test/foo', 'type' => 'phpbb-extension', - 'licence' => 'GPL v2', + 'license' => 'GPL v2', 'version' => '1.0.0', )); diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index 5dcb24c691..e396b7b73e 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -12,6 +12,7 @@ require_once dirname(__FILE__) . '/ext/vendor2/foo/mcp/a_info.php'; require_once dirname(__FILE__) . '/ext/vendor2/foo/acp/fail_info.php'; require_once dirname(__FILE__) . '/ext/vendor2/bar/acp/a_info.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_module.php'; class phpbb_extension_modules_test extends phpbb_test_case { @@ -59,7 +60,7 @@ class phpbb_extension_modules_test extends phpbb_test_case 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( - 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + 'config' => array('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')), ), ), 'acp_foobar' => array( @@ -133,7 +134,7 @@ class phpbb_extension_modules_test extends phpbb_test_case 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array ( - 'config' => array ('title' => 'Config', 'auth' => '', 'cat' => array ('ACP_MODS')), + 'config' => array ('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array ('ACP_MODS')), ), ), ), $acp_modules); @@ -157,7 +158,7 @@ class phpbb_extension_modules_test extends phpbb_test_case 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( - 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + 'config' => array('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')), ), ), 'acp_foobar' => array( @@ -191,4 +192,43 @@ class phpbb_extension_modules_test extends phpbb_test_case ) ), $acp_modules); } + + public function module_auth_test_data() + { + return array( + // module_auth, expected result + array('ext_foo', false), + array('ext_foo/bar', false), + array('ext_vendor3/bar', false), + array('ext_vendor2/foo', true), + ); + } + + /** + * @dataProvider module_auth_test_data + */ + public function test_modules_auth($module_auth, $expected) + { + global $phpbb_extension_manager, $phpbb_dispatcher; + + $phpbb_extension_manager = $this->extension_manager = new phpbb_mock_extension_manager( + dirname(__FILE__) . '/', + array( + 'vendor2/foo' => array( + 'ext_name' => 'vendor2/foo', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor2/foo/', + ), + 'vendor3/bar' => array( + 'ext_name' => 'vendor3/bar', + 'ext_active' => '0', + 'ext_path' => 'ext/vendor3/bar/', + ), + ) + ); + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + + $this->assertEquals($expected, p_master::module_auth($module_auth, 0)); + } } |
