Skip to content

Commit

Permalink
don't declare class properties dynamically to be compatible with php8…
Browse files Browse the repository at this point in the history
….2, update trigger_event_cm_viewed::execute calls
  • Loading branch information
Glutamat42 committed Sep 2, 2024
1 parent 7583bd4 commit 5c7059d
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions tests/external/trigger_event_cm_viewed_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use local_adler\lib\adler_externallib_testcase;
use local_adler\local\exceptions\not_an_adler_cm_exception;
use local_adler\local\exceptions\not_an_adler_course_exception;
use stdClass;


global $CFG;
Expand All @@ -21,6 +22,11 @@
* @runTestsInSeparateProcesses
*/
class trigger_event_cm_viewed_test extends adler_externallib_testcase {
private stdClass $user;
private stdClass $course;
private stdClass $resource_module;
private stdClass $h5p_module;

public function setUp(): void {
parent::setUp();

Expand Down Expand Up @@ -52,7 +58,7 @@ public function test_not_adler_course() {
$this->expectException(not_an_adler_course_exception::class);

// call execute
trigger_event_cm_viewed::execute($this->resource_module->cmid, true);
trigger_event_cm_viewed::execute($this->resource_module->cmid);
}

public function test_not_adler_cm() {
Expand All @@ -65,29 +71,22 @@ public function test_not_adler_cm() {
->create_adler_course_object($this->course->id);

// call execute
trigger_event_cm_viewed::execute($this->resource_module->cmid, true);
trigger_event_cm_viewed::execute($this->resource_module->cmid);
}

public function test_execute_integration() {
$adler_generator = $this->getDataGenerator()->get_plugin_generator('local_adler');

// make course adler course
$this
->getDataGenerator()
->get_plugin_generator('local_adler')
->create_adler_course_object($this->course->id);
$adler_generator->create_adler_course_object($this->course->id);

// make both modules adler modules
$resource_adler_cm = $this
->getDataGenerator()
->get_plugin_generator('local_adler')
->create_adler_course_module($this->resource_module->cmid);
$h5p_adler_cm = $this
->getDataGenerator()
->get_plugin_generator('local_adler')
->create_adler_course_module($this->h5p_module->cmid);
$resource_adler_cm = $adler_generator->create_adler_course_module($this->resource_module->cmid);
$adler_generator->create_adler_course_module($this->h5p_module->cmid);

// call execute for both modules
$result_resource = trigger_event_cm_viewed::execute($this->resource_module->cmid, true);
$result_h5p = trigger_event_cm_viewed::execute($this->h5p_module->cmid, true);
$result_resource = trigger_event_cm_viewed::execute($this->resource_module->cmid);
$result_h5p = trigger_event_cm_viewed::execute($this->h5p_module->cmid);

// assert both modules are marked as viewed
$resource_cm_info = get_fast_modinfo($this->course->id)->get_cm($this->resource_module->cmid);
Expand Down

0 comments on commit 5c7059d

Please sign in to comment.