Added generic trait for article comment tests
authorMarcel Werk <burntime@woltlab.com>
Fri, 6 May 2022 21:46:46 +0000 (23:46 +0200)
committerMarcel Werk <burntime@woltlab.com>
Fri, 6 May 2022 21:46:46 +0000 (23:46 +0200)
wcfsetup/install/files/lib/system/user/notification/event/TTestableArticleCommentUserNotificationEvent.class.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/lib/system/user/notification/event/TTestableArticleCommentUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/TTestableArticleCommentUserNotificationEvent.class.php
new file mode 100644 (file)
index 0000000..69e468b
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+namespace wcf\system\user\notification\event;
+
+use wcf\data\article\category\ArticleCategory;
+use wcf\data\user\UserProfile;
+use wcf\system\comment\CommentHandler;
+
+/**
+ * Provides a default implementation of
+ *  `TTestableCommentUserNotificationEvent::getTestCommentObjectData()`
+ * used for article comment-related and article comment response-related user notification
+ * events.
+ *
+ * @author  Marcel Werk
+ * @copyright   2001-2022 WoltLab GmbH
+ * @license WoltLab License <http://www.woltlab.com/license-agreement.html>
+ * @package WoltLabSuite\Core\System\User\Notification\Event
+ * @since   5.5
+ */
+trait TTestableArticleCommentUserNotificationEvent
+{
+    use TTestableArticleUserNotificationEvent;
+    use TTestableCategorizedUserNotificationEvent;
+
+    /**
+     * @see TTestableCommentUserNotificationEvent::createTestComment()
+     */
+    protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author)
+    {
+        return [
+            'objectID' => self::getTestArticle(self::createTestCategory(ArticleCategory::OBJECT_TYPE_NAME), $author)
+                ->getArticleContent()
+                ->articleContentID,
+            'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.articleComment'),
+        ];
+    }
+}