Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix BookingCodesMessage:sendMessage() wrong $attachment for prepareMail #1606

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Messages/BookingCodesMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function sendMessage(): bool {
'item' => $timeframe->getItem(),
'location' => $timeframe->getLocation(),
],
[ $attachment]
$attachment
);

add_action( 'commonsbooking_mail_sent',array($this,'updateEmailSent'), 5, 2 );
Expand Down
9 changes: 9 additions & 0 deletions tests/php/Service/BookingCodesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ public function testSendBookingCodesMessage() {
$this->assertMatchesRegularExpression('/' . implode('|',self::bookingCodes) . '/',$email->get_sent()->body);
}

/* As testSendBookingCodesMessage but cover the case when Ical is attached */
public function testSendBookingCodesMessageWithICal() {

// enable sending of Ical attachment
Settings::updateOption( 'commonsbooking_options_bookingcodes', 'mail-booking-codes-attach-ical', 'on');

$this->testSendBookingCodesMessage();
}

/* Tests some exceptional calculations for emailing booking codes (range and next event) */
public function testGetCronParams() {
$this->setCronParams(strtotime("2020-02-29"),strtotime("2023-01-15"));
Expand Down
7 changes: 7 additions & 0 deletions tests/php/View/BookingCodesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public function testEmailCodes() {
$this->assertMatchesRegularExpression('/' . implode('|',self::bookingCodes) . '/',$email->get_sent()->body);
}

/* As above but cover the case when ical is attached */
public function testEmailCodesWithIcal() {

Settings::updateOption( 'commonsbooking_options_bookingcodes', 'mail-booking-codes-attach-ical', 'on');

$this->testEmailCodes();
}

public function testInitialCronEmailEvent() {
$todayDate = new \DateTime(self::CURRENT_DATE);
Expand Down