From da501ae93d4b9026a9330fd86adea1411ff21b19 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 d90dbf4bf0e..ac7ff4ed39c 100644 --- a/mod/forum/tests/privacy_provider_test.php +++ b/mod/forum/tests/privacy_provider_test.php @@ -1470,10 +1470,13 @@ class mod_forum_privacy_provider_testcase extends \core_privacy\tests\provider_t // 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 @@ class mod_forum_privacy_provider_testcase extends \core_privacy\tests\provider_t // 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)); } /**