3 namespace wcf\system\user\notification\event;
5 use wcf\data\moderation\queue\ModerationQueue;
6 use wcf\data\object\type\ObjectTypeCache;
7 use wcf\data\user\UserProfile;
8 use wcf\system\moderation\queue\ModerationQueueManager;
9 use wcf\system\moderation\queue\ModerationQueueReportManager;
13 * Provides a method to create a moderation queue entry for testing user notification
16 * @author Matthias Schmidt
17 * @copyright 2001-2019 WoltLab GmbH
18 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
21 trait TTestableModerationQueueUserNotificationEvent
24 * Creates a moderation queue entry for a reported user.
26 * @param UserProfile $reportedUser
27 * @param UserProfile $reportingUser
28 * @return ModerationQueue
30 public static function getTestUserModerationQueueEntry(UserProfile $reportedUser, UserProfile $reportingUser)
32 $objectTypeID = ModerationQueueReportManager::getInstance()->getObjectTypeID('com.woltlab.wcf.user');
34 $originalUser = WCF::getUser();
35 WCF::getSession()->changeUser($reportingUser->getDecoratedObject(), true);
37 ModerationQueueReportManager::getInstance()->addReport(
38 ObjectTypeCache::getInstance()->getObjectType($objectTypeID)->objectType,
39 $reportedUser->userID,
43 WCF::getSession()->changeUser($originalUser, true);
46 FROM wcf" . WCF_N . "_moderation_queue
47 WHERE objectTypeID = ?
49 $statement = WCF::getDB()->prepareStatement($sql);
50 $statement->execute([$objectTypeID, $reportedUser->userID]);
52 $moderationQueue = $statement->fetchObject(ModerationQueue::class);
54 ModerationQueueManager::getInstance()->setAssignment([$moderationQueue->queueID => true]);
56 return $moderationQueue;