From a5f32cd356dc5b02f86b58ec2ab1947e3a582536 Mon Sep 17 00:00:00 2001 From: Prokyonn Date: Fri, 29 Sep 2023 15:09:34 +0200 Subject: [PATCH] Fix tests --- Controller/WebsiteCommentController.php | 2 +- EventSubscriber/CommentSerializationSubscriber.php | 5 ++--- composer.json | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Controller/WebsiteCommentController.php b/Controller/WebsiteCommentController.php index 7692bd6f..e4c2f096 100644 --- a/Controller/WebsiteCommentController.php +++ b/Controller/WebsiteCommentController.php @@ -355,7 +355,7 @@ public function deleteCommentAction(string $threadId, string $commentId, Request */ protected function view($data = null, $statusCode = null, array $headers = []) { - $view = parent::view($data, intval($statusCode), $headers); + $view = parent::view($data, $statusCode ? (int) $statusCode : null, $headers); $context = new Context(); $context->setGroups($this->commentSerializationGroups); diff --git a/EventSubscriber/CommentSerializationSubscriber.php b/EventSubscriber/CommentSerializationSubscriber.php index b1e116db..77643908 100644 --- a/EventSubscriber/CommentSerializationSubscriber.php +++ b/EventSubscriber/CommentSerializationSubscriber.php @@ -57,9 +57,8 @@ public function onPostSerialize(ObjectEvent $event): void { $context = $event->getContext(); /** @var mixed[] $groups */ - $groups = $context->getAttribute('groups'); - if (!$context->hasAttribute('groups') - || !in_array('commentWithAvatar', $groups)) { + $groups = $context->hasAttribute('groups') ? $context->getAttribute('groups') : []; + if (!in_array('commentWithAvatar', $groups)) { return; } diff --git a/composer.json b/composer.json index 53311f1f..2667d137 100644 --- a/composer.json +++ b/composer.json @@ -94,8 +94,7 @@ "config": { "sort-packages": true, "allow-plugins": { - "php-http/discovery": true, - "ocramius/package-versions": true + "php-http/discovery": true } } }