mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 05:18:52 +00:00
[ticket/14703] Add test for the case multiple parent module_langname found
PHPBB3-14703
This commit is contained in:
parent
eaafb758ce
commit
8cf2790d55
3 changed files with 94 additions and 6 deletions
|
@ -495,13 +495,13 @@ class module implements \phpbb\db\migration\tool\tool_interface
|
||||||
// Several modules with the given module_langname were found
|
// Several modules with the given module_langname were found
|
||||||
// Try to determine the parent_id by the neighbour module parent
|
// Try to determine the parent_id by the neighbour module parent
|
||||||
default:
|
default:
|
||||||
if (!empty($data) && (isset($data['before']) || isset($data['after'])))
|
if (isset($data['before']) || isset($data['after']))
|
||||||
{
|
{
|
||||||
$neighbour_module_langname = isset($data['before']) ? $data['before'] : $data['after'];
|
$neighbour_module_langname = isset($data['before']) ? $data['before'] : $data['after'];
|
||||||
$sql = 'SELECT parent_id
|
$sql = 'SELECT parent_id
|
||||||
FROM ' . MODULES_TABLE . '
|
FROM ' . MODULES_TABLE . "
|
||||||
WHERE module_langname ' . $this->db->sql_escape($neighbour_module_langname) . '
|
WHERE module_langname = '" . $this->db->sql_escape($neighbour_module_langname) . "'
|
||||||
AND ' . $this->db->sql_in_set('parent_id', $ids);
|
AND " . $this->db->sql_in_set('parent_id', $ids);
|
||||||
$result = $this->db->sql_query($sql);
|
$result = $this->db->sql_query($sql);
|
||||||
$parent_id = (int) $this->db->sql_fetchfield('parent_id');
|
$parent_id = (int) $this->db->sql_fetchfield('parent_id');
|
||||||
if (!$parent_id)
|
if (!$parent_id)
|
||||||
|
@ -509,8 +509,10 @@ class module implements \phpbb\db\migration\tool\tool_interface
|
||||||
throw new \phpbb\db\migration\exception('PARENT_MODULE_FIND_ERROR', $data['parent_id']);
|
throw new \phpbb\db\migration\exception('PARENT_MODULE_FIND_ERROR', $data['parent_id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (!empty($data))
|
||||||
{
|
{
|
||||||
|
// Only throw exception whhile adding module when the $data is not empty
|
||||||
|
// Otherwise it's just removing or existance checking and no need for exception
|
||||||
throw new \phpbb\db\migration\exception('MODULE_EXIST_MULTIPLE', $parent_id);
|
throw new \phpbb\db\migration\exception('MODULE_EXIST_MULTIPLE', $parent_id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<value>acp</value>
|
<value>acp</value>
|
||||||
<value>0</value>
|
<value>0</value>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
<value>4</value>
|
<value>6</value>
|
||||||
<value>ACP_CAT</value>
|
<value>ACP_CAT</value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value></value>
|
<value></value>
|
||||||
|
@ -38,5 +38,57 @@
|
||||||
<value>test</value>
|
<value>test</value>
|
||||||
<value></value>
|
<value></value>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>3</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value></value>
|
||||||
|
<value>acp</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>4</value>
|
||||||
|
<value>5</value>
|
||||||
|
<value>ACP_FORUM_BASED_PERMISSIONS</value>
|
||||||
|
<value></value>
|
||||||
|
<value></value>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>4</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value></value>
|
||||||
|
<value>acp</value>
|
||||||
|
<value>0</value>
|
||||||
|
<value>7</value>
|
||||||
|
<value>12</value>
|
||||||
|
<value>ACP_CAT_FORUMS</value>
|
||||||
|
<value></value>
|
||||||
|
<value></value>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>5</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value></value>
|
||||||
|
<value>acp</value>
|
||||||
|
<value>4</value>
|
||||||
|
<value>8</value>
|
||||||
|
<value>11</value>
|
||||||
|
<value>ACP_FORUM_BASED_PERMISSIONS</value>
|
||||||
|
<value></value>
|
||||||
|
<value></value>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>6</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value></value>
|
||||||
|
<value>acp</value>
|
||||||
|
<value>5</value>
|
||||||
|
<value>9</value>
|
||||||
|
<value>10</value>
|
||||||
|
<value>ACP_FORUM_BASED_PERMISSIONS_CHILD_1</value>
|
||||||
|
<value></value>
|
||||||
|
<value></value>
|
||||||
|
</row>
|
||||||
</table>
|
</table>
|
||||||
</dataset>
|
</dataset>
|
||||||
|
|
|
@ -118,6 +118,40 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
|
||||||
$this->fail($e);
|
$this->fail($e);
|
||||||
}
|
}
|
||||||
$this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE'));
|
$this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE'));
|
||||||
|
|
||||||
|
// Test adding module when plural parent module_langname exists
|
||||||
|
// PHPBB3-14703
|
||||||
|
// Adding fail
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$this->tool->add('acp', 'ACP_FORUM_BASED_PERMISSIONS', array(
|
||||||
|
'module_basename' => 'acp_new_permissions_module',
|
||||||
|
'module_langname' => 'ACP_NEW_PERMISSIONS_MODULE',
|
||||||
|
'module_mode' => 'test',
|
||||||
|
'module_auth' => '',
|
||||||
|
));
|
||||||
|
$this->fail('Exception not thrown');
|
||||||
|
}
|
||||||
|
catch (Exception $e) {}
|
||||||
|
|
||||||
|
// Test adding module when plural parent module_langname exists
|
||||||
|
// PHPBB3-14703
|
||||||
|
// Adding success
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$this->tool->add('acp', 'ACP_FORUM_BASED_PERMISSIONS', array(
|
||||||
|
'module_basename' => 'acp_new_permissions_module',
|
||||||
|
'module_langname' => 'ACP_NEW_PERMISSIONS_MODULE',
|
||||||
|
'module_mode' => 'test',
|
||||||
|
'module_auth' => '',
|
||||||
|
'after' => 'ACP_FORUM_BASED_PERMISSIONS_CHILD_1',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
$this->fail($e);
|
||||||
|
}
|
||||||
|
$this->assertEquals(true, $this->tool->exists('acp', 'ACP_FORUM_BASED_PERMISSIONS', 'ACP_NEW_PERMISSIONS_MODULE'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_remove()
|
public function test_remove()
|
||||||
|
|
Loading…
Add table
Reference in a new issue