From ccc7e00cc02f23a0b4e3d1507579ee44a03e8c47 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Tue, 16 Jul 2019 19:33:35 +0300 Subject: [PATCH] MDL-66163 mod_forum: Add component to unittest sql queries files from other components may exist in the files table --- mod/forum/tests/privacy_provider_test.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mod/forum/tests/privacy_provider_test.php b/mod/forum/tests/privacy_provider_test.php index d90dbf4bf0e50..ac7ff4ed39cd7 100644 --- a/mod/forum/tests/privacy_provider_test.php +++ b/mod/forum/tests/privacy_provider_test.php @@ -1470,10 +1470,13 @@ public function test_delete_data_for_user() { // 5 users * 2 forums * 1 file in each forum // Original total: 10 // One post with file removed. - $this->assertCount(0, $DB->get_records_select('files', "itemid {$postinsql}", $postinparams)); + $componentsql = "component = 'mod_forum' AND "; + $this->assertCount(0, $DB->get_records_select('files', + "{$componentsql} itemid {$postinsql}", $postinparams)); // Files for the other posts should remain. - $this->assertCount(18, $DB->get_records_select('files', "filename <> '.' AND itemid {$otherpostinsql}", $otherpostinparams)); + $this->assertCount(18, $DB->get_records_select('files', + "{$componentsql} filename <> '.' AND itemid {$otherpostinsql}", $otherpostinparams)); } /** @@ -1678,11 +1681,14 @@ public function test_delete_data_for_users() { // 5 users * 2 forums * 1 file in each forum // Original total: 10 // One post with file removed. - $this->assertCount(0, $DB->get_records_select('files', "itemid {$postinsql}", $postinparams)); + $componentsql = "component = 'mod_forum' AND "; + $this->assertCount(0, $DB->get_records_select('files', + "{$componentsql} itemid {$postinsql}", $postinparams)); // Files for the other posts should remain. $this->assertCount(18, - $DB->get_records_select('files', "filename <> '.' AND itemid {$otherpostinsql}", $otherpostinparams)); + $DB->get_records_select('files', + "{$componentsql} filename <> '.' AND itemid {$otherpostinsql}", $otherpostinparams)); } /**