Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
- add additional pre-check to narrow down a test problem
- run a test in separate processes to be compatible with newer moodle releases
  • Loading branch information
Glutamat42 committed May 11, 2024
1 parent fac7142 commit 94c8417
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/lib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function data_provider_for_test_delete_complex_instance() {
}

/**
* @runInSeparateProcess
* @dataProvider data_provider_for_test_delete_complex_instance
*/
public function test_delete_complex_instance($withAttempt) {
Expand Down Expand Up @@ -162,6 +163,12 @@ public function test_delete_instance_failure_due_to_question_deletion_failure()
// Make the method throw an exception
$mockRepo->shouldReceive('delete_question_by_id')->andThrow(new Exception('Could not delete'));

// verify created elements before deletion
$this->assertCount(1, $DB->get_records('adleradaptivity'));
$this->assertCount(2, $DB->get_records('adleradaptivity_tasks'));
$this->assertCount(1, $DB->get_records('adleradaptivity_questions'));
$this->assertCount(1, $DB->get_records('adleradaptivity_attempts'));

// Try to delete the complex instance.
$result = adleradaptivity_delete_instance($complex_adleradaptivity_module['module']->id);

Expand Down

0 comments on commit 94c8417

Please sign in to comment.