Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed Sep 18, 2024
1 parent 41ab0d2 commit 4d5db86
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions tests/eventcheck_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ public function tearDown(): void {
public function test_checkevents(): void {
// Test the subevents.
$this->assertEquals(false, townsquaresupport_check_subplugin_events($this->testdata->subevents1));
$this->assertEquals(false, townsquaresupport_check_subplugin_events($this->testdata->subevents2));
$this->assertEquals(true, townsquaresupport_check_subplugin_events($this->testdata->subevents3));
$this->assertEquals(false, townsquaresupport_check_subplugin_events($this->testdata->subevents4));
$this->assertEquals(true, townsquaresupport_check_subplugin_events($this->testdata->subevents2));
$this->assertEquals(false, townsquaresupport_check_subplugin_events($this->testdata->subevents3));
}

// Helper functions.
Expand All @@ -84,10 +83,6 @@ private function helper_test_set_up(): void {
$incorrecteevent1 = ['courseid' => 12, 'modulename' => 'pluginname', 'instancename' => 'instance1',
'timestart' => 123456789, 'coursemoduleid' => 13, 'eventtype' => 'eventtypeone', ];

// Second incorrect event: variable 'courseid' is not a integer.
$incorrecteevent2 = ['courseid' => '6', 'modulename' => 'pluginname', 'instancename' => 'instance1', 'content' => 'hello',
'timestart' => 123456789, 'coursemoduleid' => 13, 'eventtype' => 'eventtypeone', ];

// Two completely correct events.
$correctevent1 = ['courseid' => 12, 'modulename' => 'pluginname', 'instancename' => 'instance1', 'content' => 'hello',
'timestart' => 123456789, 'coursemoduleid' => 13, 'eventtype' => 'eventtypeone', ];
Expand All @@ -97,9 +92,8 @@ private function helper_test_set_up(): void {

// Build different combinations of the events.
$this->testdata->subevents1 = [(object)$incorrecteevent1, (object)$correctevent1];
$this->testdata->subevents2 = [(object)$incorrecteevent2, (object)$correctevent2];
$this->testdata->subevents3 = [(object)$correctevent1, (object)$correctevent2];
$this->testdata->subevents4 = ['arraykey' => 'incorrectsubevent'];
$this->testdata->subevents2 = [(object)$correctevent1, (object)$correctevent2];
$this->testdata->subevents3 = ['arraykey' => 'incorrectsubevent'];
}

}

0 comments on commit 4d5db86

Please sign in to comment.