diff --git a/src/Messages/BookingCodesMessage.php b/src/Messages/BookingCodesMessage.php index a646aa558..63263bdb3 100644 --- a/src/Messages/BookingCodesMessage.php +++ b/src/Messages/BookingCodesMessage.php @@ -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 ); diff --git a/tests/php/Service/BookingCodesTest.php b/tests/php/Service/BookingCodesTest.php index 4cd78a544..20b2650fe 100644 --- a/tests/php/Service/BookingCodesTest.php +++ b/tests/php/Service/BookingCodesTest.php @@ -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")); diff --git a/tests/php/View/BookingCodesTest.php b/tests/php/View/BookingCodesTest.php index 5aca2d294..e026493a4 100644 --- a/tests/php/View/BookingCodesTest.php +++ b/tests/php/View/BookingCodesTest.php @@ -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);