From 2cd5bdf0a97a686be26be2a68b9f9f5197afc434 Mon Sep 17 00:00:00 2001 From: Prasanna LMSACE Date: Mon, 25 Sep 2023 11:07:31 +0530 Subject: [PATCH] Fixed php unit tests --- actions/notification/classes/notification.php | 9 ++------- classes/helper.php | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/actions/notification/classes/notification.php b/actions/notification/classes/notification.php index 658b49c..8b57d11 100644 --- a/actions/notification/classes/notification.php +++ b/actions/notification/classes/notification.php @@ -191,13 +191,8 @@ class notification { /** * Create the instance of the notification controller. * -<<<<<<< .mine - * @param [type] $notificationid Notification instance record id NOT autoinstanceid or notificationid. - * @return self -======= - * @param int $notificationid Notification instance record id NOT autoinstanceid. + * @param int $notificationid Notification instance record id (pulseaction_notification_ins) NOT autoinstanceid. * @return notification ->>>>>>> .theirs */ public static function instance($notificationid) { static $instance; @@ -227,7 +222,7 @@ protected function create_instance_data() { global $DB; $notification = $DB->get_record('pulseaction_notification_ins', ['id' => $this->notificationid]); - + if (empty($notification)) { throw new \moodle_exception('notificationinstancenotfound', 'pulse'); } diff --git a/classes/helper.php b/classes/helper.php index cd6a5e9..203171e 100644 --- a/classes/helper.php +++ b/classes/helper.php @@ -71,7 +71,8 @@ public static function update_emailvars($templatetext, $subject, $course, $user, $sender = $sender ? $sender : core_user::get_support_user(); // Support user. $amethods = pulse_email_vars::vars(); // List of available placeholders. // Get formatted name of the category. - $course->category = core_course_category::get($course->category)->get_formatted_name(); + $course->category = is_number($course->category) + ? core_course_category::get($course->category)->get_formatted_name() : $course->category; // Convert the placeholders timeformat to user readable. self::convert_varstime_format($course); self::convert_varstime_format($user);