mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-13 20:28:44 +01:00
Merge pull request #5158 from kasimi/ticket/15586
[ticket/15586] Fixed adding module the automatic way without specifying modes
This commit is contained in:
commit
ff171f3a3b
@ -519,12 +519,6 @@ class module implements \phpbb\db\migration\tool\tool_interface
|
||||
// Allow '' to be sent as 0
|
||||
$parent_id = $parent_id ?: 0;
|
||||
|
||||
// If automatic adding is in action, convert array back to string to simplify things
|
||||
if (is_array($data) && count($data) == 1)
|
||||
{
|
||||
$data = $data['module_langname'];
|
||||
}
|
||||
|
||||
if (!is_numeric($parent_id))
|
||||
{
|
||||
// Refresh the $module_categories array
|
||||
|
37
tests/dbal/ext/foo/bar/acp/acp_test_info.php
Normal file
37
tests/dbal/ext/foo/bar/acp/acp_test_info.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace foo\bar\acp;
|
||||
|
||||
class acp_test_info
|
||||
{
|
||||
public function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => '\foo\bar\acp\acp_test_module',
|
||||
'title' => 'ACP_NEW_MODULE',
|
||||
'modes' => array(
|
||||
'mode_1' => array(
|
||||
'title' => 'ACP_NEW_MODULE_MODE_1',
|
||||
'auth' => '',
|
||||
'cat' => array('ACP_NEW_MODULE'),
|
||||
),
|
||||
'mode_2' => array(
|
||||
'title' => 'ACP_NEW_MODULE_MODE_2',
|
||||
'auth' => '',
|
||||
'cat' => array('ACP_NEW_MODULE'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
25
tests/dbal/ext/foo/bar/acp/acp_test_module.php
Normal file
25
tests/dbal/ext/foo/bar/acp/acp_test_module.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace foo\bar\acp;
|
||||
|
||||
class acp_test_module
|
||||
{
|
||||
var $u_action;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
$this->tpl_name = 'foobar';
|
||||
$this->page_title = 'Bertie';
|
||||
}
|
||||
}
|
24
tests/dbal/ext/foo/bar/composer.json
Normal file
24
tests/dbal/ext/foo/bar/composer.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "foo/bar",
|
||||
"type": "phpbb-extension",
|
||||
"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",
|
||||
"license": "GNU GPL v2",
|
||||
"authors": [{
|
||||
"name": "John Smith",
|
||||
"username": "JohnSmith27",
|
||||
"email": "email@phpbb.com",
|
||||
"homepage": "http://phpbb.com",
|
||||
"role": "N/A"
|
||||
}],
|
||||
"require": {
|
||||
"php": ">=5.4.7"
|
||||
},
|
||||
"extra": {
|
||||
"display-name": "phpBB BarFoo Extension",
|
||||
"soft-require": {
|
||||
"phpbb/phpbb": "3.2.*@dev"
|
||||
}
|
||||
}
|
||||
}
|
37
tests/dbal/ext/foo/bar/ucp/ucp_test_info.php
Normal file
37
tests/dbal/ext/foo/bar/ucp/ucp_test_info.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace foo\bar\ucp;
|
||||
|
||||
class ucp_test_info
|
||||
{
|
||||
public function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => '\foo\bar\ucp\ucp_test_module',
|
||||
'title' => 'UCP_NEW_MODULE',
|
||||
'modes' => array(
|
||||
'mode_1' => array(
|
||||
'title' => 'UCP_NEW_MODULE_MODE_1',
|
||||
'auth' => '',
|
||||
'cat' => array('UCP_NEW_MODULE'),
|
||||
),
|
||||
'mode_2' => array(
|
||||
'title' => 'UCP_NEW_MODULE_MODE_2',
|
||||
'auth' => '',
|
||||
'cat' => array('UCP_NEW_MODULE'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
25
tests/dbal/ext/foo/bar/ucp/ucp_test_module.php
Normal file
25
tests/dbal/ext/foo/bar/ucp/ucp_test_module.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace foo\bar\ucp;
|
||||
|
||||
class ucp_test_module
|
||||
{
|
||||
var $u_action;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
$this->tpl_name = 'foobar';
|
||||
$this->page_title = 'Bertie';
|
||||
}
|
||||
}
|
@ -11,6 +11,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/ext/foo/bar/acp/acp_test_info.php';
|
||||
require_once dirname(__FILE__) . '/ext/foo/bar/ucp/ucp_test_info.php';
|
||||
|
||||
class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
@ -39,6 +42,9 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
|
||||
$auth = $this->getMock('\phpbb\auth\auth');
|
||||
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
|
||||
|
||||
// Correctly set the root path for this test to this directory, so the classes can be found
|
||||
$phpbb_root_path = dirname(__FILE__) . '/';
|
||||
|
||||
$phpbb_extension_manager = new phpbb_mock_extension_manager($phpbb_root_path);
|
||||
$module_manager = new \phpbb\module\module_manager($cache, $this->db, $phpbb_extension_manager, MODULES_TABLE, $phpbb_root_path, $phpEx);
|
||||
|
||||
@ -403,6 +409,35 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
|
||||
$this->fail($e);
|
||||
}
|
||||
$this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_SUBCAT', 'UCP_NEW_MODULE'));
|
||||
|
||||
// Test adding new UCP module the automatic way, single mode
|
||||
try
|
||||
{
|
||||
$this->tool->add('ucp', 'UCP_NEW_CAT', array(
|
||||
'module_basename' => '\foo\bar\ucp\ucp_test_module',
|
||||
'modes' => array('mode_1'),
|
||||
));
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->fail($e);
|
||||
}
|
||||
$this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_MODULE_MODE_1'));
|
||||
$this->assertEquals(false, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_MODULE_MODE_2'));
|
||||
|
||||
// Test adding new ACP module the automatic way, all modes
|
||||
try
|
||||
{
|
||||
$this->tool->add('acp', 'ACP_NEW_CAT', array(
|
||||
'module_basename' => '\foo\bar\acp\acp_test_module',
|
||||
));
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->fail($e);
|
||||
}
|
||||
$this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE_MODE_1'));
|
||||
$this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE_MODE_2'));
|
||||
}
|
||||
|
||||
public function test_remove()
|
||||
|
Loading…
x
Reference in New Issue
Block a user