Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
34.95% covered (danger)
34.95%
130 / 372
60.00% covered (warning)
60.00%
6 / 10
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_functions_user_delete_user_test
34.95% covered (danger)
34.95%
130 / 372
60.00% covered (warning)
60.00%
6 / 10
44.31
0.00% covered (danger)
0.00%
0 / 1
 getDataSet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUp
100.00% covered (success)
100.00%
34 / 34
100.00% covered (success)
100.00%
1 / 1
1
 first_last_post_data
0.00% covered (danger)
0.00%
0 / 126
0.00% covered (danger)
0.00%
0 / 1
2
 test_first_last_post_info
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
1 / 1
1
 report_attachment_data
0.00% covered (danger)
0.00%
0 / 44
0.00% covered (danger)
0.00%
0 / 1
2
 test_report_attachment_info
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
1 / 1
1
 delete_data
0.00% covered (danger)
0.00%
0 / 32
0.00% covered (danger)
0.00%
0 / 1
2
 test_delete_data
100.00% covered (success)
100.00%
37 / 37
100.00% covered (success)
100.00%
1 / 1
1
 delete_user_id_data
0.00% covered (danger)
0.00%
0 / 40
0.00% covered (danger)
0.00%
0 / 1
2
 test_delete_user_id_data
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3*
4* @package testing
5* @copyright (c) 2014 phpBB Group
6* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7*
8*/
9
10require_once __DIR__ . '/../../phpBB/includes/functions_user.php';
11
12class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
13{
14    /** @var \phpbb\db\driver\driver_interface */
15    protected $db;
16
17    public function getDataSet()
18    {
19        return $this->createXMLDataSet(__DIR__ . '/fixtures/delete_user.xml');
20    }
21
22    protected function setUp(): void
23    {
24        parent::setUp();
25
26        global $cache, $config, $db, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx;
27
28        $db = $this->db = $this->new_dbal();
29
30        $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
31        $lang = new \phpbb\language\language($lang_loader);
32        $user = new \phpbb\user($lang, '\phpbb\datetime');
33
34        $config = new \phpbb\config\config(array(
35            'load_online_time'    => 5,
36            'search_type'        => '\phpbb\search\backend\fulltext_mysql',
37        ));
38        $cache = new phpbb_mock_null_cache();
39        $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
40        $phpbb_container = new phpbb_mock_container_builder();
41        $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
42
43        $storage = $this->createMock('\phpbb\storage\storage');
44
45        // Works as a workaround for tests
46        $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage));
47        $phpbb_container->set(
48            'auth.provider.db',
49            new phpbb_mock_auth_provider()
50        );
51        $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config);
52        $provider_collection->add('auth.provider.db');
53        $phpbb_container->set(
54            'auth.provider_collection',
55            $provider_collection
56        );
57
58        $search_backend = $this->createMock(\phpbb\search\backend\search_backend_interface::class);
59        $search_backend_factory = $this->createMock(\phpbb\search\search_backend_factory::class);
60        $search_backend_factory->method('get_active')->willReturn($search_backend);
61        $phpbb_container->set('search.backend_factory', $search_backend_factory);
62
63
64        $phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens');
65        $phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states');
66        $phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts');
67
68        $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
69    }
70
71     public static function first_last_post_data()
72    {
73        return array(
74            array(
75                'retain', false,
76                array(
77                    array('post_id' => 1, 'poster_id' => ANONYMOUS, 'post_username' => 'Guest'),
78                    array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
79                    array('post_id' => 3, 'poster_id' => ANONYMOUS, 'post_username' => 'Guest'),
80                    array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
81                ),
82                array(
83                    array(
84                        'topic_id' => 1,
85                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Guest', 'topic_first_poster_colour' => '',
86                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Guest', 'topic_last_poster_colour' => '',
87                    ),
88                    array(
89                        'topic_id' => 2,
90                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
91                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
92                    ),
93                    array(
94                        'topic_id' => 3,
95                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Guest', 'topic_first_poster_colour' => '',
96                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Guest', 'topic_last_poster_colour' => '',
97                    ),
98                    array(
99                        'topic_id' => 4,
100                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
101                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
102                    ),
103                ),
104                array(
105                    array('forum_id' => 1, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Guest', 'forum_last_poster_colour' => ''),
106                    array('forum_id' => 2, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
107                    array('forum_id' => 3, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Guest', 'forum_last_poster_colour' => ''),
108                    array('forum_id' => 4, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
109                ),
110            ),
111            array(
112                'remove', false,
113                array(
114                    array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
115                    array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
116                ),
117                array(
118                    array(
119                        'topic_id' => 2,
120                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
121                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
122                    ),
123                    array(
124                        'topic_id' => 4,
125                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
126                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
127                    ),
128                ),
129                array(
130                    array('forum_id' => 1, 'forum_last_poster_id' => 0, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
131                    array('forum_id' => 2, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
132                    array('forum_id' => 3, 'forum_last_poster_id' => 0, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
133                    array('forum_id' => 4, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
134                ),
135            ),
136            array(
137                'retain', true,
138                array(
139                    array('post_id' => 1, 'poster_id' => ANONYMOUS, 'post_username' => 'Foobar'),
140                    array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
141                    array('post_id' => 3, 'poster_id' => ANONYMOUS, 'post_username' => 'Foobar'),
142                    array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
143                ),
144                array(
145                    array(
146                        'topic_id' => 1,
147                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Foobar', 'topic_first_poster_colour' => '',
148                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Foobar', 'topic_last_poster_colour' => '',
149                    ),
150                    array(
151                        'topic_id' => 2,
152                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
153                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
154                    ),
155                    array(
156                        'topic_id' => 3,
157                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Foobar', 'topic_first_poster_colour' => '',
158                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Foobar', 'topic_last_poster_colour' => '',
159                    ),
160                    array(
161                        'topic_id' => 4,
162                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
163                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
164                    ),
165                ),
166                array(
167                    array('forum_id' => 1, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Foobar', 'forum_last_poster_colour' => ''),
168                    array('forum_id' => 2, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
169                    array('forum_id' => 3, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Foobar', 'forum_last_poster_colour' => ''),
170                    array('forum_id' => 4, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
171                ),
172            ),
173            array(
174                'remove', true,
175                array(
176                    array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
177                    array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
178                ),
179                array(
180                    array(
181                        'topic_id' => 2,
182                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
183                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
184                    ),
185                    array(
186                        'topic_id' => 4,
187                        'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Other', 'topic_first_poster_colour' => '',
188                        'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Other', 'topic_last_poster_colour' => '',
189                    ),
190                ),
191                array(
192                    array('forum_id' => 1, 'forum_last_poster_id' => 0, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
193                    array('forum_id' => 2, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
194                    array('forum_id' => 3, 'forum_last_poster_id' => 0, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
195                    array('forum_id' => 4, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
196                ),
197            ),
198        );
199    }
200
201    /**
202    * @dataProvider first_last_post_data
203    */
204    public function test_first_last_post_info($mode, $retain_username, $expected_posts, $expected_topics, $expected_forums)
205    {
206        $this->assertFalse(user_delete($mode, 2, $retain_username));
207
208        $sql = 'SELECT post_id, poster_id, post_username
209            FROM ' . POSTS_TABLE . '
210            ORDER BY post_id ASC';
211        $result = $this->db->sql_query($sql);
212        $this->assertEquals($expected_posts, $this->db->sql_fetchrowset($result), 'Post table poster info is mismatching after deleting a user.');
213        $this->db->sql_freeresult($result);
214
215        $sql = 'SELECT topic_id, topic_poster, topic_first_poster_name, topic_first_poster_colour, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour
216            FROM ' . TOPICS_TABLE . '
217            ORDER BY topic_id ASC';
218        $result = $this->db->sql_query($sql);
219        $this->assertEquals($expected_topics, $this->db->sql_fetchrowset($result), 'Topic table first/last poster info is mismatching after deleting a user.');
220        $this->db->sql_freeresult($result);
221
222        $sql = 'SELECT forum_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour
223            FROM ' . FORUMS_TABLE . '
224            ORDER BY forum_id ASC';
225        $result = $this->db->sql_query($sql);
226        $this->assertEquals($expected_forums, $this->db->sql_fetchrowset($result), 'Forum table last poster info is mismatching after deleting a user.');
227        $this->db->sql_freeresult($result);
228    }
229
230     public static function report_attachment_data()
231    {
232        return array(
233            array(
234                'retain',
235                array(
236                    array('post_id' => 1, 'post_reported' => 1, 'post_edit_user' => 1, 'post_delete_user' => 1),
237                    array('post_id' => 2, 'post_reported' => 1, 'post_edit_user' => 1, 'post_delete_user' => 1),
238                    array('post_id' => 3, 'post_reported' => 0, 'post_edit_user' => 1, 'post_delete_user' => 1),
239                    array('post_id' => 4, 'post_reported' => 0, 'post_edit_user' => 1, 'post_delete_user' => 1),
240                ),
241                array(
242                    array('report_id' => 1, 'post_id' => 1, 'user_id' => 1),
243                    array('report_id' => 3, 'post_id' => 2, 'user_id' => 1),
244                ),
245                array(
246                    array('topic_id' => 1, 'topic_reported' => 1, 'topic_delete_user' => 1),
247                    array('topic_id' => 2, 'topic_reported' => 1, 'topic_delete_user' => 1),
248                    array('topic_id' => 3, 'topic_reported' => 0, 'topic_delete_user' => 1),
249                    array('topic_id' => 4, 'topic_reported' => 0, 'topic_delete_user' => 1),
250                ),
251                array(
252                    array('attach_id' => 1, 'post_msg_id' => 1, 'poster_id' => 1),
253                    array('attach_id' => 2, 'post_msg_id' => 2, 'poster_id' => 1),
254                    array('attach_id' => 3, 'post_msg_id' => 0, 'poster_id' => 1), // TODO should be deleted: PHPBB3-13089
255                ),
256            ),
257            array(
258                'remove',
259                array(
260                    array('post_id' => 2, 'post_reported' => 1, 'post_edit_user' => 1, 'post_delete_user' => 1),
261                    array('post_id' => 4, 'post_reported' => 0, 'post_edit_user' => 1, 'post_delete_user' => 1),
262                ),
263                array(
264                    array('report_id' => 3, 'post_id' => 2, 'user_id' => 1),
265                ),
266                array(
267                    array('topic_id' => 2, 'topic_reported' => 1, 'topic_delete_user' => 1),
268                    array('topic_id' => 4, 'topic_reported' => 0, 'topic_delete_user' => 1),
269                ),
270                array(
271                    array('attach_id' => 2, 'post_msg_id' => 2, 'poster_id' => 1),
272                    array('attach_id' => 3, 'post_msg_id' => 0, 'poster_id' => 2), // TODO should be deleted: PHPBB3-13089
273                ),
274            ),
275        );
276    }
277
278    /**
279    * @dataProvider report_attachment_data
280    */
281    public function test_report_attachment_info($mode, $expected_posts, $expected_reports, $expected_topics, $expected_attach)
282    {
283        $this->assertFalse(user_delete($mode, 2));
284
285        $sql = 'SELECT post_id, post_reported, post_edit_user, post_delete_user
286            FROM ' . POSTS_TABLE . '
287            ORDER BY post_id ASC';
288        $result = $this->db->sql_query($sql);
289        $this->assertEquals($expected_posts, $this->db->sql_fetchrowset($result), 'Post report status content is mismatching after deleting a user.');
290        $this->db->sql_freeresult($result);
291
292        $sql = 'SELECT report_id, post_id, user_id
293            FROM ' . REPORTS_TABLE . '
294            ORDER BY report_id ASC';
295        $result = $this->db->sql_query($sql);
296        $this->assertEquals($expected_reports, $this->db->sql_fetchrowset($result), 'Report table content is mismatching after deleting a user.');
297        $this->db->sql_freeresult($result);
298
299        $sql = 'SELECT topic_id, topic_reported, topic_delete_user
300            FROM ' . TOPICS_TABLE . '
301            ORDER BY topic_id ASC';
302        $result = $this->db->sql_query($sql);
303        $this->assertEquals($expected_topics, $this->db->sql_fetchrowset($result), 'Topic report status is mismatching after deleting a user.');
304        $this->db->sql_freeresult($result);
305
306        $sql = 'SELECT attach_id, post_msg_id, poster_id
307            FROM ' . ATTACHMENTS_TABLE . '
308            ORDER BY attach_id ASC';
309        $result = $this->db->sql_query($sql);
310        $this->assertEquals($expected_attach, $this->db->sql_fetchrowset($result), 'Attachment table content is mismatching after deleting a user.');
311        $this->db->sql_freeresult($result);
312    }
313
314     public static function delete_data()
315    {
316        return array(
317            array(
318                'retain',
319                array(array('user_id' => 1, 'user_posts' => 4)),
320                array(array('user_id' => 1, 'zebra_id' => 3)),
321                array(array('ban_id' => 2), array('ban_id' => 3)),
322                array(array('session_id' => '12345678901234567890123456789013')),
323                array(
324                    array('log_id' => 2, 'user_id' => 1, 'reportee_id' => 1),
325                    array('log_id' => 3, 'user_id' => 1, 'reportee_id' => 1),
326                ),
327                array(
328                    array('msg_id' => 1, 'author_id' => 3, 'message_edit_user' => 3),
329                    array('msg_id' => 2, 'author_id' => 1, 'message_edit_user' => 1),
330                ),
331            ),
332            array(
333                'remove',
334                array(array('user_id' => 1, 'user_posts' => 2)),
335                array(array('user_id' => 1, 'zebra_id' => 3)),
336                array(array('ban_id' => 2), array('ban_id' => 3)),
337                array(array('session_id' => '12345678901234567890123456789013')),
338                array(
339                    array('log_id' => 2, 'user_id' => 1, 'reportee_id' => 1),
340                    array('log_id' => 3, 'user_id' => 1, 'reportee_id' => 1),
341                ),
342                array(
343                    array('msg_id' => 1, 'author_id' => 3, 'message_edit_user' => 3),
344                    array('msg_id' => 2, 'author_id' => 1, 'message_edit_user' => 1),
345                ),
346            ),
347        );
348    }
349
350    /**
351    * @dataProvider delete_data
352    */
353    public function test_delete_data($mode, $expected_users, $expected_zebra, $expected_ban, $expected_sessions, $expected_logs, $expected_pms)
354    {
355        $this->assertFalse(user_delete($mode, 2));
356
357        $sql = 'SELECT user_id, user_posts
358            FROM ' . USERS_TABLE . '
359            ORDER BY user_id ASC';
360        $result = $this->db->sql_query($sql);
361        $this->assertEquals($expected_users, $this->db->sql_fetchrowset($result), 'User table content is mismatching after deleting a user.');
362        $this->db->sql_freeresult($result);
363
364        $sql = 'SELECT user_id, zebra_id
365            FROM ' . ZEBRA_TABLE . '
366            ORDER BY user_id ASC, zebra_id ASC';
367        $result = $this->db->sql_query($sql);
368        $this->assertEquals($expected_zebra, $this->db->sql_fetchrowset($result), 'Zebra table content is mismatching after deleting a user.');
369        $this->db->sql_freeresult($result);
370
371        $sql = 'SELECT ban_id
372            FROM ' . BANS_TABLE . '
373            ORDER BY ban_id ASC';
374        $result = $this->db->sql_query($sql);
375        $this->assertEquals($expected_ban, $this->db->sql_fetchrowset($result), 'Ban table content is mismatching after deleting a user.');
376        $this->db->sql_freeresult($result);
377
378        $sql = 'SELECT session_id
379            FROM ' . SESSIONS_TABLE . '
380            ORDER BY session_id ASC';
381        $result = $this->db->sql_query($sql);
382        $this->assertEquals($expected_sessions, $this->db->sql_fetchrowset($result), 'Session table content is mismatching after deleting a user.');
383        $this->db->sql_freeresult($result);
384
385        $sql = 'SELECT log_id, user_id, reportee_id
386            FROM ' . LOG_TABLE . '
387            ORDER BY log_id ASC';
388        $result = $this->db->sql_query($sql);
389        $this->assertEquals($expected_logs, $this->db->sql_fetchrowset($result), 'Log table content is mismatching after deleting a user.');
390        $this->db->sql_freeresult($result);
391
392        $sql = 'SELECT msg_id, author_id, message_edit_user
393            FROM ' . PRIVMSGS_TABLE . '
394            ORDER BY msg_id ASC';
395        $result = $this->db->sql_query($sql);
396        $this->assertEquals($expected_pms, $this->db->sql_fetchrowset($result), 'Private messages table content is mismatching after deleting a user.');
397        $this->db->sql_freeresult($result);
398    }
399
400     public static function delete_user_id_data()
401    {
402        return array(
403            array(
404                'retain',
405                array(
406                    USER_GROUP_TABLE,
407                    TOPICS_WATCH_TABLE,
408                    FORUMS_WATCH_TABLE,
409                    ACL_USERS_TABLE,
410                    TOPICS_TRACK_TABLE,
411                    TOPICS_POSTED_TABLE,
412                    FORUMS_TRACK_TABLE,
413                    PROFILE_FIELDS_DATA_TABLE,
414                    MODERATOR_CACHE_TABLE,
415                    DRAFTS_TABLE,
416                    BOOKMARKS_TABLE,
417                    SESSIONS_KEYS_TABLE,
418                    PRIVMSGS_FOLDER_TABLE,
419                    PRIVMSGS_RULES_TABLE,
420                ),
421            ),
422            array(
423                'remove',
424                array(
425                    USER_GROUP_TABLE,
426                    TOPICS_WATCH_TABLE,
427                    FORUMS_WATCH_TABLE,
428                    ACL_USERS_TABLE,
429                    TOPICS_TRACK_TABLE,
430                    TOPICS_POSTED_TABLE,
431                    FORUMS_TRACK_TABLE,
432                    PROFILE_FIELDS_DATA_TABLE,
433                    MODERATOR_CACHE_TABLE,
434                    DRAFTS_TABLE,
435                    BOOKMARKS_TABLE,
436                    SESSIONS_KEYS_TABLE,
437                    PRIVMSGS_FOLDER_TABLE,
438                    PRIVMSGS_RULES_TABLE,
439                ),
440            ),
441        );
442    }
443
444    /**
445    * @dataProvider delete_user_id_data
446    */
447    public function test_delete_user_id_data($mode, $cleaned_tables)
448    {
449        $this->assertFalse(user_delete($mode, 2));
450
451        foreach ($cleaned_tables as $table)
452        {
453            $sql = 'SELECT user_id
454                FROM ' . $table . '
455                WHERE user_id = 2';
456            $result = $this->db->sql_query($sql);
457            $this->assertFalse($this->db->sql_fetchfield('user_id'), 'Found data for deleted user in table: ' . $table);
458            $this->db->sql_freeresult($result);
459
460            $sql = 'SELECT user_id
461                FROM ' . $table . '
462                WHERE user_id = 3';
463            $result = $this->db->sql_query($sql);
464            $this->assertEquals(3, $this->db->sql_fetchfield('user_id'), 'Missing data for user in table: ' . $table);
465            $this->db->sql_freeresult($result);
466        }
467    }
468}