MDL-44552 Events: Fixed wrong id returned in get_url

This commit is contained in:
Rajesh Taneja 2014-03-13 13:19:07 +08:00
parent c0e88129d1
commit b54696395d
6 changed files with 10 additions and 10 deletions

View File

@ -39,7 +39,7 @@ class comment_created extends \core\event\comment_created {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/data/view.php', array('id' => $this->other['itemid']));
return new \moodle_url('/mod/data/view.php', array('id' => $this->contextinstanceid));
}
/**

View File

@ -39,7 +39,7 @@ class comment_deleted extends \core\event\comment_deleted {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/data/view.php', array('id' => $this->other['itemid']));
return new \moodle_url('/mod/data/view.php', array('id' => $this->contextinstanceid));
}
/**

View File

@ -163,7 +163,7 @@ class data_lib_testcase extends advanced_testcase {
// Checking that the event contains the expected values.
$this->assertInstanceOf('\mod_data\event\comment_created', $event);
$this->assertEquals($context, $event->get_context());
$url = new moodle_url('/mod/data/view.php', array('id' => $module->id));
$url = new moodle_url('/mod/data/view.php', array('id' => $module->cmid));
$this->assertEquals($url, $event->get_url());
$this->assertEventContextNotUsed($event);
}
@ -227,7 +227,7 @@ class data_lib_testcase extends advanced_testcase {
// Checking that the event contains the expected values.
$this->assertInstanceOf('\mod_data\event\comment_deleted', $event);
$this->assertEquals($context, $event->get_context());
$url = new moodle_url('/mod/data/view.php', array('id' => $module->id));
$url = new moodle_url('/mod/data/view.php', array('id' => $module->cmid));
$this->assertEquals($url, $event->get_url());
$this->assertEventContextNotUsed($event);
}

View File

@ -39,7 +39,7 @@ class comment_created extends \core\event\comment_created {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/glossary/view.php', array('id' => $this->other['itemid']));
return new \moodle_url('/mod/glossary/view.php', array('id' => $this->contextinstanceid));
}
/**

View File

@ -39,7 +39,7 @@ class comment_deleted extends \core\event\comment_deleted {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/glossary/view.php', array('id' => $this->other['itemid']));
return new \moodle_url('/mod/glossary/view.php', array('id' => $this->contextinstanceid));
}
/**

View File

@ -39,7 +39,7 @@ class glossary_event_testcase extends advanced_testcase {
* Test comment_created event.
*/
public function test_comment_created() {
global $CFG, $DB;
global $CFG;
require_once($CFG->dirroot . '/comment/lib.php');
$this->resetAfterTest();
@ -74,7 +74,7 @@ class glossary_event_testcase extends advanced_testcase {
// Checking that the event contains the expected values.
$this->assertInstanceOf('\mod_glossary\event\comment_created', $event);
$this->assertEquals($context, $event->get_context());
$url = new moodle_url('/mod/glossary/view.php', array('id' => $glossary->id));
$url = new moodle_url('/mod/glossary/view.php', array('id' => $glossary->cmid));
$this->assertEquals($url, $event->get_url());
$this->assertEventContextNotUsed($event);
}
@ -83,7 +83,7 @@ class glossary_event_testcase extends advanced_testcase {
* Test comment_deleted event.
*/
public function test_comment_deleted() {
global $CFG, $DB;
global $CFG;
require_once($CFG->dirroot . '/comment/lib.php');
$this->resetAfterTest();
@ -119,7 +119,7 @@ class glossary_event_testcase extends advanced_testcase {
// Checking that the event contains the expected values.
$this->assertInstanceOf('\mod_glossary\event\comment_deleted', $event);
$this->assertEquals($context, $event->get_context());
$url = new moodle_url('/mod/glossary/view.php', array('id' => $glossary->id));
$url = new moodle_url('/mod/glossary/view.php', array('id' => $glossary->cmid));
$this->assertEquals($url, $event->get_url());
$this->assertEventContextNotUsed($event);
}