[ticket/16895] Adjust test

PHPBB3-16895
This commit is contained in:
rxu 2021-10-27 00:15:46 +07:00
parent b1e6fad38a
commit 7275cdd152
No known key found for this signature in database
GPG key ID: 955F0567380E586A
2 changed files with 13 additions and 6 deletions

View file

@ -21,7 +21,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
/** @var \phpbb\auth\auth */ /** @var \phpbb\auth\auth */
protected $auth; protected $auth;
/** @var \includes\acp\acp_auth */ /** @var \includes\acp\auth\auth_admin */
protected $auth_admin; protected $auth_admin;
/** @var \phpbb\cache\service */ /** @var \phpbb\cache\service */

View file

@ -16,7 +16,7 @@ class phpbb_dbal_migrator_tool_permission_role_test extends phpbb_database_test_
/** @var \phpbb\auth\auth */ /** @var \phpbb\auth\auth */
protected $auth; protected $auth;
/** @var \acp\auth\auth_admin */ /** @var \includes\acp\auth\auth_admin */
protected $auth_admin; protected $auth_admin;
/** @var \phpbb\db\migration\tool\permission */ /** @var \phpbb\db\migration\tool\permission */
@ -171,19 +171,26 @@ class phpbb_dbal_migrator_tool_permission_role_test extends phpbb_database_test_
$group_id = (int) $this->group_ids[$group_name]; $group_id = (int) $this->group_ids[$group_name];
$role_id = (int) $this->new_role_ids[$role_name]; $role_id = (int) $this->new_role_ids[$role_name];
$sql = 'SELECT agt.auth_role_id
FROM ' . ACL_GROUPS_TABLE . ' agt, ' . ACL_ROLES_TABLE . ' art
WHERE agt.auth_role_id = art.role_id
AND art.role_id = ' . $role_id;
// Set auth options for each role // Set auth options for each role
$this->tool->permission_set($role_name, $auth_option, 'role', true); $this->tool->permission_set($role_name, $auth_option, 'role', true);
// Assign roles to groups // Assign roles to groups
$this->auth_admin->acl_set($ug_type, $forum_id, $group_id, $auth, $role_id); $this->auth_admin->acl_set($ug_type, $forum_id, $group_id, $auth, $role_id);
// Check if the role is assigned to the group
$result = $this->db->sql_query($sql);
$this->assertEquals($role_id, $this->db->sql_fetchfield('auth_role_id'));
$this->db->sql_freeresult($result);
$this->tool->role_remove($role_name); $this->tool->role_remove($role_name);
$this->assertFalse((bool) $this->tool->role_exists($role_name)); $this->assertFalse((bool) $this->tool->role_exists($role_name));
$sql = 'SELECT agt.auth_role_id // Check if the role is unassigned
FROM ' . ACL_GROUPS_TABLE . ' agt, ' . ACL_ROLES_TABLE . ' art
WHERE agt.auth_role_id = art.role_id
AND art.role_id = ' . $role_id;
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
$this->assertFalse($this->db->sql_fetchfield('auth_role_id')); $this->assertFalse($this->db->sql_fetchfield('auth_role_id'));
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);