MDL-45837 core: minor tidy up to events

This commit is contained in:
Mark Nelson 2018-02-09 11:58:02 +08:00
parent b302d434ae
commit e960152141
7 changed files with 28 additions and 38 deletions

View File

@ -29,7 +29,7 @@ global $CFG;
require_once($CFG->dirroot . '/grade/lib.php');
/**
* Unit tests for grade/lib.php.
* Unit tests for grade events.
*
* @package core_grades
* @category test
@ -54,14 +54,13 @@ class core_grade_events_test extends advanced_testcase {
}
/**
* Test the grade_letter added event.
* Test the grade letter created event.
*
* There is no external API for triggering this event, so the unit test will simply
* create and trigger the event and ensure the data is returned as expected.
*/
public function test_grade_letter_created() {
// Create a scale aded event.
// Create a grade letter created event.
$event = \core\event\grade_letter_created::create(array(
'objectid' => 10,
'context' => context_course::instance($this->course->id)
@ -79,14 +78,13 @@ class core_grade_events_test extends advanced_testcase {
}
/**
* Test the grade_letter deleted event.
* Test the grade letter deleted event.
*
* There is no external API for triggering this event, so the unit test will simply
* create and trigger the event and ensure the data is returned as expected.
*/
public function test_grade_letter_deleted() {
// Create a grade_letter deleted event.
// Create a grade letter deleted event.
$event = \core\event\grade_letter_deleted::create(array(
'objectid' => 10,
'context' => context_course::instance($this->course->id)
@ -104,14 +102,13 @@ class core_grade_events_test extends advanced_testcase {
}
/**
* Test the grade_letter updated event.
* Test the grade letter updated event.
*
* There is no external API for triggering this event, so the unit test will simply
* create and trigger the event and ensure the data is returned as expected.
*/
public function test_grade_letter_updated() {
// Create a scale updated event.
// Create a grade letter updated event.
$event = \core\event\grade_letter_updated::create(array(
'objectid' => 10,
'context' => context_course::instance($this->course->id)
@ -128,17 +125,11 @@ class core_grade_events_test extends advanced_testcase {
$this->assertEquals(context_course::instance($this->course->id), $event->get_context());
}
/**
* Test the scale added event.
*
* There is no external API for triggering this event, so the unit test will simply
* create and trigger the event and ensure the data is returned as expected.
* Test the scale created event.
*/
public function test_scale_created() {
$gradescale = new grade_scale();
$gradescale->name = 'unittestscale3';
$gradescale->courseid = $this->course->id;
$gradescale->userid = 317;
@ -162,14 +153,9 @@ class core_grade_events_test extends advanced_testcase {
/**
* Test the scale deleted event.
*
* There is no external API for triggering this event, so the unit test will simply
* create and trigger the event and ensure the data is returned as expected.
*/
public function test_scale_deleted() {
$gradescale = new grade_scale();
$gradescale->name = 'unittestscale3';
$gradescale->courseid = $this->course->id;
$gradescale->userid = 317;
@ -190,12 +176,8 @@ class core_grade_events_test extends advanced_testcase {
/**
* Test the scale updated event.
*
* There is no external API for triggering this event, so the unit test will simply
* create and trigger the event and ensure the data is returned as expected.
*/
public function test_scale_updated() {
$gradescale = new grade_scale();
$gradescale->name = 'unittestscale3';
$gradescale->courseid = $this->course->id;

View File

@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Grade letter added created.
* Grade letter created event.
*
* @package core
* @copyright 2017 Stephen Bourget
@ -27,7 +27,7 @@ namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Grade letter added event class.
* Grade letter created event class.
*
* @package core
* @since Moodle 3.5

View File

@ -65,13 +65,14 @@ class grade_letter_deleted extends base {
if ($this->courseid) {
return "The user with id '$this->userid' deleted the letter grade with id '$this->objectid'".
" from the course in the id '".$this->courseid."'.";
} else {
return "The user with id '$this->userid' deleted the letter grade with id '$this->objectid'.";
}
return "The user with id '$this->userid' deleted the letter grade with id '$this->objectid'.";
}
/**
* Used for mapping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {

View File

@ -27,7 +27,7 @@ namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Grade letter added event class.
* Grade letter updated event class.
*
* @package core
* @since Moodle 3.5
@ -72,6 +72,7 @@ class grade_letter_updated extends base {
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
@ -84,6 +85,7 @@ class grade_letter_updated extends base {
/**
* Used for mapping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {

View File

@ -65,13 +65,14 @@ class scale_created extends base {
if ($this->courseid) {
return "The user with id '$this->userid' created the custom scale with id '$this->objectid'".
" from the course in the id '".$this->courseid."'.";
} else {
return "The user with id '$this->userid' created the standard scale with id '$this->objectid'.";
}
return "The user with id '$this->userid' created the standard scale with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
@ -84,6 +85,7 @@ class scale_created extends base {
/**
* Used for mapping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {

View File

@ -65,13 +65,14 @@ class scale_deleted extends base {
if ($this->courseid) {
return "The user with id '$this->userid' deleted the custom scale with id '$this->objectid'".
" from the course with the id '".$this->courseid."'.";
} else {
return "The user with id '$this->userid' deleted the standard scale with id '$this->objectid'.";
}
return "The user with id '$this->userid' deleted the standard scale with id '$this->objectid'.";
}
/**
* Used for mapping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {

View File

@ -27,7 +27,7 @@ namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Scale added event class.
* Scale updated event class.
*
* @package core
* @since Moodle 3.5
@ -65,13 +65,14 @@ class scale_updated extends base {
if ($this->courseid) {
return "The user with id '$this->userid' updated the custom scale with id '$this->objectid'".
" from the course in the id '".$this->courseid."'.";
} else {
return "The user with id '$this->userid' updated the standard scale with id '$this->objectid'.";
}
return "The user with id '$this->userid' updated the standard scale with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
@ -84,6 +85,7 @@ class scale_updated extends base {
/**
* Used for mapping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {