MDL-66163 mod_forum: Add component to unittest sql queries
authorMarina Glancy <marina@moodle.com>
Tue, 16 Jul 2019 16:33:35 +0000 (19:33 +0300)
committerMarina Glancy <marina@moodle.com>
Tue, 16 Jul 2019 17:36:05 +0000 (20:36 +0300)
files from other components may exist in the files table

mod/forum/tests/privacy_provider_test.php

index d90dbf4..ac7ff4e 100644 (file)
@@ -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));
     }
 
     /**