Skip to content

Commit ccc7e00

Browse files
committed
MDL-66163 mod_forum: Add component to unittest sql queries
files from other components may exist in the files table
1 parent 39ef515 commit ccc7e00

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

mod/forum/tests/privacy_provider_test.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,10 +1470,13 @@ public function test_delete_data_for_user() {
14701470
// 5 users * 2 forums * 1 file in each forum
14711471
// Original total: 10
14721472
// One post with file removed.
1473-
$this->assertCount(0, $DB->get_records_select('files', "itemid {$postinsql}", $postinparams));
1473+
$componentsql = "component = 'mod_forum' AND ";
1474+
$this->assertCount(0, $DB->get_records_select('files',
1475+
"{$componentsql} itemid {$postinsql}", $postinparams));
14741476

14751477
// Files for the other posts should remain.
1476-
$this->assertCount(18, $DB->get_records_select('files', "filename <> '.' AND itemid {$otherpostinsql}", $otherpostinparams));
1478+
$this->assertCount(18, $DB->get_records_select('files',
1479+
"{$componentsql} filename <> '.' AND itemid {$otherpostinsql}", $otherpostinparams));
14771480
}
14781481

14791482
/**
@@ -1678,11 +1681,14 @@ public function test_delete_data_for_users() {
16781681
// 5 users * 2 forums * 1 file in each forum
16791682
// Original total: 10
16801683
// One post with file removed.
1681-
$this->assertCount(0, $DB->get_records_select('files', "itemid {$postinsql}", $postinparams));
1684+
$componentsql = "component = 'mod_forum' AND ";
1685+
$this->assertCount(0, $DB->get_records_select('files',
1686+
"{$componentsql} itemid {$postinsql}", $postinparams));
16821687

16831688
// Files for the other posts should remain.
16841689
$this->assertCount(18,
1685-
$DB->get_records_select('files', "filename <> '.' AND itemid {$otherpostinsql}", $otherpostinparams));
1690+
$DB->get_records_select('files',
1691+
"{$componentsql} filename <> '.' AND itemid {$otherpostinsql}", $otherpostinparams));
16861692
}
16871693

16881694
/**

0 commit comments

Comments
 (0)