mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 12:45:04 +01:00
MDL-65017 mod_forum: Test based on event type and not objectid
* Plus fix warning about \test_capability_manager::can_delete_post()
This commit is contained in:
parent
9f1af3771d
commit
acdce3a0e4
@ -1631,10 +1631,9 @@ class mod_forum_events_testcase extends advanced_testcase {
|
||||
|
||||
// Loop through the events and check they are valid.
|
||||
foreach ($events as $event) {
|
||||
|
||||
if ($event->objectid == $discussion->id) {
|
||||
if ($event instanceof \mod_forum\event\discussion_deleted) {
|
||||
// Check that the event contains the expected values.
|
||||
$this->assertInstanceOf('\mod_forum\event\discussion_deleted', $event);
|
||||
$this->assertEquals($event->objectid, $discussion->id);
|
||||
$this->assertEquals(context_module::instance($forum->cmid), $event->get_context());
|
||||
$expected = array($course->id, 'forum', 'delete discussion', "view.php?id={$forum->cmid}",
|
||||
$forum->id, $forum->cmid);
|
||||
@ -1647,6 +1646,7 @@ class mod_forum_events_testcase extends advanced_testcase {
|
||||
$post = $posts[$event->objectid];
|
||||
// Check that the event contains the expected values.
|
||||
$this->assertInstanceOf('\mod_forum\event\post_deleted', $event);
|
||||
$this->assertEquals($event->objectid, $post->id);
|
||||
$this->assertEquals(context_module::instance($forum->cmid), $event->get_context());
|
||||
$expected = array($course->id, 'forum', 'delete post', "discuss.php?d={$discussion->id}", $post->id, $forum->cmid);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
|
@ -485,9 +485,11 @@ class test_capability_manager extends capability_manager {
|
||||
* @param stdClass $user The user
|
||||
* @param discussion_entity $discussion The discussion
|
||||
* @param post_entity $post The post
|
||||
* @param bool $hasreplies
|
||||
* @return bool
|
||||
*/
|
||||
public function can_delete_post(stdClass $user, discussion_entity $discussion, post_entity $post) : bool {
|
||||
public function can_delete_post(stdClass $user, discussion_entity $discussion, post_entity $post,
|
||||
bool $hasreplies = false) : bool {
|
||||
return $this->delete;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user