Skip to content

Commit

Permalink
Bugfix: Correct tear down for complete instance
Browse files Browse the repository at this point in the history
  • Loading branch information
eynimeni committed Dec 5, 2024
1 parent 8013a49 commit 48d0230
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions classes/singleton_service.php
Original file line number Diff line number Diff line change
Expand Up @@ -808,4 +808,14 @@ public static function get_all_booking_instances() {

return $instance->allbookinginstances;
}

/**
* Destroys the singleton entirely.
*
* @return bool
*/
public static function destroy_instance() {
self::$instance = null;
return true;
}
}
10 changes: 10 additions & 0 deletions tests/bo_availability/condition_all_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,7 @@ public function test_booking_bookit_overlapping(array $bdata): void {
*/
public function test_booking_bookit_overlapping_sessions(array $bdata): void {
global $DB, $CFG;
$this->tearDown();

// Setup test data.
$course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
Expand Down Expand Up @@ -1624,4 +1625,13 @@ public static function booking_common_settings_provider(): array {
];
return ['bdata' => [$bdata]];
}

/**
* Mandatory clean-up after each test.
*/
public function tearDown(): void {
parent::tearDown();
// Mandatory clean-up.
singleton_service::destroy_instance();
}
}

0 comments on commit 48d0230

Please sign in to comment.