2 namespace wcf\system\user\notification\event;
3 use wcf\data\comment\Comment;
4 use wcf\data\comment\CommentAction;
5 use wcf\data\user\UserProfile;
6 use wcf\system\user\notification\object\CommentUserNotificationObject;
7 use wcf\system\user\notification\object\IUserNotificationObject;
10 * Default implementation of some methods of the testable user notification event interface
11 * for comment user notificiation events.
13 * As PHP 5.5 does not support abstract static functions in traits, we require them by this documentation:
14 * - protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author)
15 * returns the `objectID` and `objectTypeID` parameter for comment creation.
17 * @author Matthias Schmidt
18 * @copyright 2001-2017 WoltLab GmbH
19 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
20 * @package WoltLabSuite\Core\System\User\Notification\Event
23 trait TTestableCommentUserNotificationEvent {
24 use TTestableUserNotificationEvent;
29 public static function canBeTriggeredByGuests() {
34 * Creates a test comment.
36 * @param UserProfile $recipient
37 * @param UserProfile $author
40 public static function createTestComment(UserProfile $recipient, UserProfile $author) {
41 return (new CommentAction([], 'create', [
42 'data' => array_merge([
45 'message' => '<p>Test Comment</p>',
46 'time' => TIME_NOW - 10,
47 'userID' => $recipient->userID,
48 'username' => $recipient->username
49 ], self::getTestCommentObjectData($recipient, $author))
50 ]))->executeAction()['returnValues'];
54 * @see ITestableUserNotificationEvent::getTestAdditionalData()
56 public static function getTestAdditionalData(IUserNotificationObject $object) {
57 /** @var CommentUserNotificationObject $object */
59 return ['objectUserID' => $object->objectID];
64 * @return CommentUserNotificationObject[]
66 public static function getTestObjects(UserProfile $recipient, UserProfile $author) {
67 return [new CommentUserNotificationObject(self::createTestComment($recipient, $author))];