1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-21 16:22:22 +02:00

[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');
// Create a new standard user if needed, topic and post to test searh for author
$searchforauthoruser_name = 'searchforauthoruser';
$searchforauthoruser_id = null; // if the user exists, array with user_id will be returned
if (!$this->user_exists($searchforauthoruser_name, $searchforauthoruser_id))
if (!$searchforauthoruser_id = $this->user_exists('searchforauthoruser'))
{
$searchforauthoruser_id = $this->create_user('searchforauthoruser');
}
else
{
$searchforauthoruser_id = (int) $searchforauthoruser_id[0];
$searchforauthoruser_id = key($searchforauthoruser_id);
}
$this->remove_user_group('NEWLY_REGISTERED', ['searchforauthoruser']);
$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->add_lang('posting');
$username = 'ucp-file-test';
if (!$this->user_exists($username))
if (!$this->user_exists('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 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;
@ -1540,6 +1540,8 @@ class phpbb_functional_test_case extends phpbb_test_case
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;
}
}