Skip to content

Commit

Permalink
Tests: Fix tests & linting
Browse files Browse the repository at this point in the history
  • Loading branch information
georgmaisser committed Jan 21, 2025
1 parent 0c77734 commit 41d1676
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 44 deletions.
17 changes: 5 additions & 12 deletions tests/bookitbutton/bookitbutton_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,14 @@ public function setUp(): void {
*
* @covers \booking_bookit
*
* @param array $bdata
* @param array $users
* @param array $courses
* @param array $expected
* @param array $coursedata
* @param mixed $pricecategories
* @param mixed $expected
*
* @throws \coding_exception
* @throws \dml_exception
*
* @dataProvider booking_common_settings_provider
*
* @return void
*/
public function test_booking_bookit_with_price_and_cancellation(array $coursedata, $pricecategories, $expected): void {
global $DB, $CFG;
Expand Down Expand Up @@ -449,12 +448,6 @@ public static function booking_common_settings_provider(): array {
],

];

// Test 2: Standard booking instance.
// Price should be shown.



return $returnarray;
}

Expand Down
9 changes: 1 addition & 8 deletions tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,7 @@ public function create_option($record = null) {
}

// Create / save booking option(s).
if ($record->id = booking_option::update($record, $context)) {
//$record->optionid = $record->id;

// Add price (via API).
// $price = new Mod_bookingPrice('option', $record->id);
// $price->set_data($record);
// booking_option::update($record, $context);
}
$record->id = booking_option::update($record, $context);

return $record;
}
Expand Down
48 changes: 24 additions & 24 deletions tests/shopping_cart/shopping_cart_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ public function test_booking_bookit_subbookings_item_price(array $bdata): void {
$record->courseid = $course->id;
$record->useprice = 1; // Use price from the default category.
$record->maxanswers = 3;
$record->optiondateid_1 = "0";
$record->daystonotify_1 = "0";
$record->coursestarttime_1 = strtotime('now + 3 day');
$record->courseendtime_1 = strtotime('now + 6 day');
$record->optiondateid_0 = "0";
$record->daystonotify_0 = "0";
$record->coursestarttime_0 = strtotime('now + 3 day');
$record->courseendtime_0 = strtotime('now + 6 day');
$record->importing = 1;

/** @var mod_booking_generator $plugingenerator */
Expand Down Expand Up @@ -1204,48 +1204,48 @@ public static function booking_common_settings_provider(): array {
'text' => 'Test Option 1',
'courseid' => 0,
'maxanswers' => 2,
'optiondateid_1' => "0",
'daystonotify_1' => "0",
'coursestarttime_1' => strtotime('20 May 2050 15:00'),
'courseendtime_1' => strtotime('20 June 2050 14:00'),
'optiondateid_0' => "0",
'daystonotify_0' => "0",
'coursestarttime_0' => strtotime('20 May 2050 15:00'),
'courseendtime_0' => strtotime('20 June 2050 14:00'),
],
// Option 2 with 1 session started tomorrow.
1 => [
'text' => 'Test Option 2',
'courseid' => 0,
'maxanswers' => 4,
'optiondateid_1' => "0",
'daystonotify_1' => "0",
'coursestarttime_1' => strtotime('now +1 day'),
'courseendtime_1' => strtotime('now +3 day'),
'optiondateid_0' => "0",
'daystonotify_0' => "0",
'coursestarttime_0' => strtotime('now +1 day'),
'courseendtime_0' => strtotime('now +3 day'),
],
// Option 3 with 1 ongoing session started yesterday.
2 => [
'text' => 'Test Option 3',
'courseid' => 0,
'maxanswers' => 4,
'optiondateid_1' => "0",
'daystonotify_1' => "0",
'coursestarttime_1' => strtotime('now -48 hours'),
'courseendtime_1' => strtotime('now +72 hours'),
'optiondateid_0' => "0",
'daystonotify_0' => "0",
'coursestarttime_0' => strtotime('now -48 hours'),
'courseendtime_0' => strtotime('now +72 hours'),
],
// Option 3 with 1 ongoing and 2 past non-overlaping sessions.
3 => [
'text' => 'Test Option 4',
'courseid' => 0,
'maxanswers' => 4,
'optiondateid_0' => "0",
'daystonotify_0' => "0",
'coursestarttime_0' => strtotime('now -6 day'),
'courseendtime_0' => strtotime('now -5 day'),
'optiondateid_1' => "0",
'daystonotify_1' => "0",
'coursestarttime_1' => strtotime('now -6 day'),
'courseendtime_1' => strtotime('now -5 day'),
'coursestarttime_1' => strtotime('now -4 day'),
'courseendtime_1' => strtotime('now -3 day'),
'optiondateid_2' => "0",
'daystonotify_2' => "0",
'coursestarttime_2' => strtotime('now -4 day'),
'courseendtime_2' => strtotime('now -3 day'),
'optiondateid_3' => "0",
'daystonotify_3' => "0",
'coursestarttime_3' => strtotime('now -48 hours'),
'courseendtime_3' => strtotime('now +72 hours'),
'coursestarttime_2' => strtotime('now -48 hours'),
'courseendtime_2' => strtotime('now +72 hours'),
],
],
'pricecategories' => [
Expand Down

0 comments on commit 41d1676

Please sign in to comment.