1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-14 04:34:07 +02:00

[ticket/17414] Extend unit test coverage for base class

PHPBB-17414
This commit is contained in:
Marc Alexander
2024-10-17 18:40:53 +02:00
parent 38ce4985f4
commit 1e80400d09
6 changed files with 130 additions and 14 deletions

View File

@@ -65,7 +65,7 @@ class factory
function garbage_collect($name)
{
$captcha = $this->get_instance($name);
$captcha->garbage_collect(0);
$captcha->garbage_collect();
}
/**

View File

@@ -151,6 +151,7 @@ abstract class base implements plugin_interface
{
$this->code = gen_rand_string_friendly(CAPTCHA_MAX_CHARS);
$this->confirm_id = md5(unique_id());
$this->attempts = 0;
$sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
'confirm_id' => $this->confirm_id,
@@ -207,13 +208,13 @@ abstract class base implements plugin_interface
/**
* @inheritDoc
*/
public function garbage_collect(int $confirm_type = 0): void
public function garbage_collect(confirm_type $confirm_type = confirm_type::UNDEFINED): void
{
$sql = 'SELECT DISTINCT c.session_id
FROM ' . CONFIRM_TABLE . ' c
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id)
WHERE s.session_id IS NULL' .
((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type);
((empty($confirm_type)) ? '' : ' AND c.confirm_type = ' . $confirm_type->value);
$result = $this->db->sql_query($sql);
if ($row = $this->db->sql_fetchrow($result))

View File

@@ -198,11 +198,11 @@ class legacy_wrapper implements plugin_interface
/**
* {@inheritDoc}
*/
public function garbage_collect(int $confirm_type = 0): void
public function garbage_collect(confirm_type $confirm_type = confirm_type::UNDEFINED): void
{
if (method_exists($this->legacy_captcha, 'garbage_collect'))
{
$this->legacy_captcha->garbage_collect($confirm_type);
$this->legacy_captcha->garbage_collect($confirm_type->value);
}
}

View File

@@ -110,10 +110,10 @@ interface plugin_interface
/**
* Garbage collect captcha plugin
*
* @param int $confirm_type Confirm type to garbage collect, defaults to all (0)
* @param confirm_type $confirm_type Confirm type to garbage collect, defaults to all (0)
* @return void
*/
public function garbage_collect(int $confirm_type = 0): void;
public function garbage_collect(confirm_type $confirm_type = confirm_type::UNDEFINED): void;
/**
* Display acp page