[ticket/17422] Adjust tests code

PHPBB-17422
This commit is contained in:
rxu 2024-10-31 14:55:35 +07:00
parent 7086fa746f
commit 4194cb2228
No known key found for this signature in database
GPG key ID: 8117904FEDEFDD17
3 changed files with 8 additions and 9 deletions

View file

@ -117,15 +117,13 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$this->add_lang('common'); $this->add_lang('common');
// Create a new standard user if needed, topic and post to test searh for author // Create a new standard user if needed, topic and post to test searh for author
$searchforauthoruser_name = 'searchforauthoruser'; if (!$searchforauthoruser_id = $this->user_exists('searchforauthoruser'))
$searchforauthoruser_id = null; // if the user exists, array with user_id will be returned
if (!$this->user_exists($searchforauthoruser_name, $searchforauthoruser_id))
{ {
$searchforauthoruser_id = $this->create_user('searchforauthoruser'); $searchforauthoruser_id = $this->create_user('searchforauthoruser');
} }
else else
{ {
$searchforauthoruser_id = (int) $searchforauthoruser_id[0]; $searchforauthoruser_id = key($searchforauthoruser_id);
} }
$this->remove_user_group('NEWLY_REGISTERED', ['searchforauthoruser']); $this->remove_user_group('NEWLY_REGISTERED', ['searchforauthoruser']);
$this->set_flood_interval(0); $this->set_flood_interval(0);

View file

@ -24,8 +24,7 @@ class phpbb_functional_ucp_attachments_test extends phpbb_functional_test_case
$this->path = __DIR__ . '/fixtures/files/'; $this->path = __DIR__ . '/fixtures/files/';
$this->add_lang('posting'); $this->add_lang('posting');
$username = 'ucp-file-test'; if (!$this->user_exists('ucp-file-test'))
if (!$this->user_exists($username))
{ {
$this->create_user('ucp-file-test'); $this->create_user('ucp-file-test');
} }

View file

@ -1523,9 +1523,9 @@ class phpbb_functional_test_case extends phpbb_test_case
* @param string $username The username to check or empty if user_id is used * @param string $username The username to check or empty if user_id is used
* @param int $user_id The user id to check or empty if username is used * @param int $user_id The user id to check or empty if username is used
* *
* @return bool Returns true if a user exists, false otherwise * @return array Returns user_id => username array or empty array if user does not exist
*/ */
protected function user_exists(&$username, &$user_id = null) protected function user_exists($username = '', $user_id = '')
{ {
global $db; global $db;
@ -1540,6 +1540,8 @@ class phpbb_functional_test_case extends phpbb_test_case
require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); require_once(__DIR__ . '/../../phpBB/includes/functions_user.php');
} }
return user_get_id_name($user_id, $username) ? false : true; user_get_id_name($user_id, $username, false, true);
return $username;
} }
} }