From 9684f897acbe8954a12b0b8e80e6c49f87432977 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 01e5cfc24cb..df8fab0e183 100644 --- a/mod/forum/tests/privacy_provider_test.php +++ b/mod/forum/tests/privacy_provider_test.php @@ -1383,10 +1383,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)); } /** @@ -1591,11 +1594,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)); } /**