Skip to content

Commit

Permalink
MDL-39915 cleanup core_event_testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 27, 2013
1 parent 5b0d1b8 commit 96deb95
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/tests/event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function test_event_properties() {
$this->assertSame('u', $event->crud);
$this->assertSame(10, $event->level);

$this->assertSame($system, $event->get_context());
$this->assertEquals($system, $event->get_context());
$this->assertSame($system->id, $event->contextid);
$this->assertSame($system->contextlevel, $event->contextlevel);
$this->assertSame($system->instanceid, $event->contextinstanceid);
Expand Down Expand Up @@ -86,7 +86,7 @@ public function test_event_properties() {
}

$event2 = \core_tests\event\unittest_executed::create(array('courseid'=>1, 'contextid'=>$system->id, 'objectid'=>5, 'other'=>array('sample'=>null, 'xx'=>10)));
$this->assertSame($event->get_context(), $event2->get_context());
$this->assertEquals($event->get_context(), $event2->get_context());
}

public function test_observers_parsing() {
Expand Down Expand Up @@ -171,7 +171,6 @@ public function test_observers_parsing() {

$this->assertEquals($expected, $result['*']);


// Now test broken stuff...

$observers = array(
Expand Down Expand Up @@ -229,7 +228,7 @@ public function test_observers_parsing() {
$observers = array(
array(
'eventname' => '\core_tests\event\unittest_executed',
'callback' => '', // empty callable
'callback' => '', // Empty callable.
'includefile' => 'lib/tests/fixtures/event_fixtures.php',
),
);
Expand Down Expand Up @@ -415,6 +414,7 @@ public function test_external_buffer() {
$trans->rollback(new \moodle_exception('xxx'));
$this->fail('Expecting exception');
} catch (\moodle_exception $e) {
$this->assertInstanceOf('moodle_exception', $e);
}

$this->assertSame(
Expand Down Expand Up @@ -458,7 +458,6 @@ public function test_legacy() {
$event2->nest = true;
$event2->trigger();


$this->assertSame(
array('observe_all-1', 'observe_one-1', 'legacy_handler-1', 'observe_all-nesting-2', 'legacy_handler-3', 'observe_one-2', 'observe_all-3', 'observe_one-3', 'legacy_handler-2'),
\core_tests\event\unittest_observer::$info);
Expand All @@ -467,7 +466,6 @@ public function test_legacy() {
$this->assertSame($event1, \core_tests\event\unittest_observer::$event[1]);
$this->assertSame(array(1, 5), \core_tests\event\unittest_observer::$event[2]);


$logs = $DB->get_records('log', array(), 'id ASC');
$this->assertCount(3, $logs);

Expand Down Expand Up @@ -527,7 +525,7 @@ public function test_trigger_problems() {
try {
$event->trigger();
$this->fail('Exception expected on double trigger');
} catch (Exception $e) {
} catch (\moodle_exception $e) {
$this->assertInstanceOf('coding_exception', $e);
}

Expand Down Expand Up @@ -556,7 +554,7 @@ public function test_bad_events() {
try {
$event = \core_tests\event\unittest_executed::create(array('courseid'=>1, 'other'=>array('sample'=>5, 'xx'=>10)));
$this->fail('Exception expected when context and contextid missing');
} catch (Exception $e) {
} catch (\moodle_exception $e) {
$this->assertInstanceOf('coding_exception', $e);
}

Expand Down

0 comments on commit 96deb95

Please sign in to comment.