From b13de8508d0585b748e8e0b443bd1d73b0705a98 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 9 Feb 2021 10:58:56 +0100 Subject: [PATCH] Minor - fix behat test + add behat tests. --- .github/workflows/php.yml | 12 ++++++++-- public/main/inc/lib/message.lib.php | 34 ++++++++++++++++------------- public/main/social/group_add.php | 2 +- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index b40a7273c0..c90bf4a0ca 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -195,8 +195,16 @@ jobs: ../../vendor/behat/behat/bin/behat features/sessionManagement.feature -vv ../../vendor/behat/behat/bin/behat features/socialGroup.feature -vv ../../vendor/behat/behat/bin/behat features/systemAnnouncements.feature -vv - - + ../../vendor/behat/behat/bin/behat features/ticket.feature -vv + ../../vendor/behat/behat/bin/behat features/toolAgenda.feature -vv + ../../vendor/behat/behat/bin/behat features/toolAnnouncement.feature -vv + # ../../vendor/behat/behat/bin/behat features/toolDocument.feature -v + # ../../vendor/behat/behat/bin/behat features/toolExercise.feature -v + # ../../vendor/behat/behat/bin/behat features/toolForum.feature -v + # ../../vendor/behat/behat/bin/behat features/toolGroup.feature -vv + ../../vendor/behat/behat/bin/behat features/toolLink.feature -vv + #../../vendor/behat/behat/bin/behat features/toolLp.feature -vvv + ../../vendor/behat/behat/bin/behat features/toolWork.feature -vvv - name: Composer analyse run: composer analyse diff --git a/public/main/inc/lib/message.lib.php b/public/main/inc/lib/message.lib.php index 4f58bbd7b2..c02b1f7025 100644 --- a/public/main/inc/lib/message.lib.php +++ b/public/main/inc/lib/message.lib.php @@ -617,6 +617,12 @@ class MessageManager $table = Database::get_main_table(TABLE_MESSAGE); $em = Database::getManager(); + $repo = $em->getRepository(Message::class); + $parent = null; + if (!empty($parent_id)) { + $parent = $repo->find($parent_id); + } + $message = null; // Just in case we replace the and \n and \n\r while saving in the DB @@ -631,8 +637,6 @@ class MessageManager Database::query($query); $messageId = $editMessageId; } else { - $repo = $em->getRepository(Message::class); - $parent = $repo->find($parent_id); $message = new Message(); $message ->setUserSender($userSender) @@ -649,7 +653,6 @@ class MessageManager } // Forward also message attachments. - $forwardAttachments = []; if (!empty($forwardId)) { $forwardMessage = $repo->find($forwardId); if (null !== $forwardMessage) { @@ -681,18 +684,19 @@ class MessageManager // Save message in the outbox for user friend or group. if (empty($group_id) && MESSAGE_STATUS_UNREAD === $status) { - $params = [ - 'user_sender_id' => $user_sender_id, - 'user_receiver_id' => $receiverUserId, - 'msg_status' => MESSAGE_STATUS_OUTBOX, - 'send_date' => $now, - 'title' => $subject, - 'content' => $content, - 'group_id' => $group_id, - 'parent_id' => $parent_id, - 'update_date' => $now, - ]; - Database::insert($table, $params); + $message = new Message(); + $message + ->setUserSender($userSender) + ->setUserReceiver($userRecipient) + ->setMsgStatus(MESSAGE_STATUS_OUTBOX) + ->setTitle($subject) + ->setContent($content) + ->setGroupId($group_id) + ->setParent($parent) + ; + $em->persist($message); + $em->flush(); + $messageId = $message->getId(); // save attachment file for outbox messages /*if (is_array($attachmentList)) { diff --git a/public/main/social/group_add.php b/public/main/social/group_add.php index 19fc9e5a8d..20b4c88848 100644 --- a/public/main/social/group_add.php +++ b/public/main/social/group_add.php @@ -21,7 +21,7 @@ $table_message = Database::get_main_table(TABLE_MESSAGE); $usergroup = new UserGroup(); $form = new FormValidator('add_group'); $usergroup->setGroupType($usergroup::SOCIAL_CLASS); -$usergroup->setForm($form, 'add', []); +$usergroup->setForm($form, 'add'); if ($form->validate()) { $values = $form->exportValues();