// 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);
$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);
* @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;
}