Commit | Line | Data |
---|---|---|
5adcd121 | 1 | <?php |
fea86294 | 2 | |
5adcd121 | 3 | namespace wcf\system\user\notification\event; |
fea86294 | 4 | |
5ba6c275 MS |
5 | use wcf\data\conversation\Conversation; |
6 | use wcf\data\conversation\ConversationAction; | |
fea86294 TD |
7 | use wcf\data\conversation\message\ConversationMessage; |
8 | use wcf\data\conversation\message\ConversationMessageAction; | |
5adcd121 MS |
9 | use wcf\data\user\UserProfile; |
10 | ||
11 | /** | |
5ba6c275 MS |
12 | * Provides methods to create conversations and conversation messages for testing |
13 | * user notification events. | |
14 | * | |
fea86294 TD |
15 | * @author Matthias Schmidt |
16 | * @copyright 2001-2019 WoltLab GmbH | |
17 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
fea86294 | 18 | * @since 3.1 |
5adcd121 | 19 | */ |
fea86294 TD |
20 | trait TTestableConversationRelatedUserNotificationEvent |
21 | { | |
22 | /** | |
23 | * Creates a conversation for testing. | |
24 | * | |
25 | * @param UserProfile $conversationAuthor | |
26 | * @param UserProfile $participant | |
27 | * @return Conversation | |
28 | */ | |
29 | public static function createTestConversation(UserProfile $conversationAuthor, UserProfile $participant) | |
30 | { | |
31 | return (new ConversationAction([], 'create', [ | |
32 | 'data' => [ | |
33 | 'subject' => 'Test Conversation Subject', | |
34 | 'time' => TIME_NOW, | |
35 | 'userID' => $conversationAuthor->userID, | |
36 | 'username' => $conversationAuthor->username, | |
37 | ], | |
38 | 'messageData' => [ | |
39 | 'message' => 'Test Conversation Message', | |
40 | ], | |
41 | 'participants' => [$participant->userID], | |
42 | ]))->executeAction()['returnValues']; | |
43 | } | |
44 | ||
45 | /** | |
46 | * Creates a conversation message for testing. | |
47 | * | |
48 | * @param UserProfile $conversationAuthor | |
49 | * @param UserProfile $messageAuthor | |
50 | * @return ConversationMessage | |
51 | */ | |
52 | public static function createTestConversationMessage(UserProfile $conversationAuthor, UserProfile $messageAuthor) | |
53 | { | |
54 | $conversation = self::createTestConversation($conversationAuthor, $messageAuthor); | |
55 | ||
56 | return (new ConversationMessageAction([], 'create', [ | |
57 | 'data' => [ | |
58 | 'conversationID' => $conversation->conversationID, | |
59 | 'message' => 'Test Conversation Message Message', | |
60 | 'time' => TIME_NOW, | |
61 | 'userID' => $messageAuthor->userID, | |
62 | 'username' => $messageAuthor->username, | |
63 | ], | |
64 | 'conversation' => $conversation, | |
65 | ]))->executeAction()['returnValues']; | |
66 | } | |
5adcd121 | 67 | } |