Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
phpbb_console_user_reclean_test
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 get_command_tester
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
 test_reclean
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14use Symfony\Component\Console\Application;
15use Symfony\Component\Console\Tester\CommandTester;
16use phpbb\console\command\user\reclean;
17
18require_once __DIR__ . '/base.php';
19
20class phpbb_console_user_reclean_test extends phpbb_console_user_base
21{
22    public function get_command_tester()
23    {
24        $application = new Application();
25        $application->add(new reclean(
26            $this->user,
27            $this->db,
28            $this->language
29        ));
30
31        $command = $application->find('user:reclean');
32
33        return new CommandTester($command);
34    }
35
36    public function test_reclean()
37    {
38        $command_tester = $this->get_command_tester();
39
40        $exit_status = $command_tester->execute([]);
41        $this->assertSame(0, $exit_status);
42
43        $result = $this->db->sql_query('SELECT user_id FROM ' . USERS_TABLE . " WHERE username_clean = 'test unclean'");
44        $row = $this->db->sql_fetchrow($result);
45        $this->db->sql_freeresult($result);
46        $this->assertNotNull($row['user_id']);
47    }
48}