Skip to content

Commit

Permalink
try to add support fpr booking_rule reminder "ndayas before" for an i…
Browse files Browse the repository at this point in the history
…nstallment payment into the test_booking_bookit_with_price_and_installment() method. Not working (0 record in the rule_daysbefore->execute)
  • Loading branch information
semteacher committed Jul 6, 2024
1 parent d72011c commit 06340f3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/shopping_cart/shopping_cart_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use mod_booking\price;
use mod_booking_generator;
use mod_booking\bo_availability\bo_info;
use mod_booking\booking_rules\booking_rules;
use local_shopping_cart\shopping_cart;
use local_shopping_cart\shopping_cart_history;
use local_shopping_cart\local\cartstore;
Expand Down Expand Up @@ -218,6 +219,25 @@ public function test_booking_bookit_with_price_and_installment(array $bdata): vo
$exppadate = userdate(strtotime('now + 2 days'), get_string('strftimedate', 'langconfig'));
$this->assertEquals($exppadate, $installment['payments'][1]['date']);

// Trigger and capture emails.
unset_config('noemailever');
ob_start();
$messagesink = $this->redirectMessages();

// Create booking rule - "ndays before".
$ruledata = [
'name' => 'installment',
'conditionname' => 'select_user_shopping_cart',
'contextid' => 1,
'conditiondata' => '{}',
'actionname' => 'send_mail',
'actiondata' => '{"subject":"installment_custom_subj","template":"installment_custom_msg","templateformat":"1"}',
'rulename' => 'rule_daysbefore',
'ruledata' => '{"days":"2","datefield":"installmentpayment"}',
];
$rule1 = $plugingenerator->create_rule($ruledata);
//$rules = booking_rules::get_list_of_saved_rules_by_context(1);var_dump($rules);

// Confirm cash payment.
$res = shopping_cart::confirm_payment($student1->id, LOCAL_SHOPPING_CART_PAYMENT_METHOD_CREDITS);
// Validate payment.
Expand All @@ -229,6 +249,14 @@ public function test_booking_bookit_with_price_and_installment(array $bdata): vo
$option = singleton_service::get_instance_of_booking_option($settings->cmid, $settings->id);
$option->user_submit_response($student1, 0, 0, 0, MOD_BOOKING_VERIFIED);

$this->runAdhocTasks();

$messages = $messagesink->get_messages();
var_dump($messages);
$res = ob_get_clean();
var_dump($res);
$messagesink->close();

// User 1 should be booked now.
list($id, $isavailable, $description) = $boinfo->is_available($settings->id, $student1->id, true);
$this->assertEquals(MOD_BOOKING_BO_COND_ALREADYBOOKED, $id);
Expand Down

0 comments on commit 06340f3

Please sign in to comment.