1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-11 19:24:01 +02:00

[ticket/17347] Add special handling for deletion of bots

PHPBB-17347
This commit is contained in:
Marc Alexander
2024-06-21 20:48:41 +02:00
parent 09f0b417be
commit 8c77da9c30
5 changed files with 128 additions and 8 deletions

View File

@@ -13,7 +13,7 @@
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use phpbb\console\command\user\delete_ids;
use phpbb\console\command\user\delete_id;
require_once __DIR__ . '/base.php';
@@ -22,11 +22,15 @@ class phpbb_console_user_delete_ids_test extends phpbb_console_user_base
public function get_command_tester()
{
$application = new Application();
$application->add(new delete_ids(
$application->add(new delete_id(
$this->db,
$this->language,
$this->log,
$this->user,
$this->user_loader,
BOTS_TABLE,
USER_GROUP_TABLE,
USERS_TABLE,
$this->phpbb_root_path,
$this->php_ext
));
@@ -55,6 +59,42 @@ class phpbb_console_user_delete_ids_test extends phpbb_console_user_base
$this->assertStringContainsString('CLI_USER_DELETE_IDS_SUCCESS', $command_tester->getDisplay());
}
public function test_delete_one()
{
$command_tester = $this->get_command_tester();
$command_tester->setInputs(['yes', '']);
$command_tester->execute(array(
'command' => $this->command_name,
'user_ids' => [3],
'--delete-posts' => false,
));
$this->assertNull($this->get_user_id('Test'));
$this->assertNotNull($this->get_user_id('Test 2'));
$this->assertStringContainsString('CLI_USER_DELETE_IDS_SUCCESS', $command_tester->getDisplay());
}
public function test_delete_bot()
{
$command_tester = $this->get_command_tester();
$this->assertNotNull($this->get_user_id('Test Bot'));
$command_tester->setInputs(['yes', '']);
$command_tester->execute(array(
'command' => $this->command_name,
'user_ids' => [3, 6],
'--delete-posts' => false,
));
$this->assertNull($this->get_user_id('Test'));
$this->assertNull($this->get_user_id('Test Bot'));
$this->assertStringContainsString('CLI_USER_DELETE_IDS_SUCCESS', $command_tester->getDisplay());
}
public function test_delete_non_user()
{
$command_tester = $this->get_command_tester();

View File

@@ -47,6 +47,14 @@
<value></value>
<value>0</value>
</row>
<row>
<value>6</value>
<value></value>
<value>Test Bot</value>
<value>Test Bot</value>
<value></value>
<value>2</value>
</row>
</table>
<table name="phpbb_groups">
<column>group_id</column>
@@ -59,5 +67,23 @@
<value>3</value>
<value>foobar</value>
</row>
<row>
<value>6</value>
<value>BOTS</value>
<value>3</value>
<value></value>
</row>
</table>
<table name="phpbb_user_group">
<column>group_id</column>
<column>user_id</column>
<column>group_leader</column>
<column>user_pending</column>
<row>
<value>6</value>
<value>6</value>
<value>0</value>
<value>0</value>
</row>
</table>
</dataset>