-
-
Notifications
You must be signed in to change notification settings - Fork 836
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sami Mazouz <[email protected]>
- Loading branch information
Showing
1 changed file
with
12 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,25 +28,17 @@ protected function setUp(): void | |
$this->prepareDatabase([ | ||
'users' => [ | ||
$this->normalUser(), | ||
['id' => 3, 'username' => 'acme', 'email' => '[email protected]', 'is_email_confirmed' => 1, 'preferences' => json_encode(['flarum-subscriptions.notify_for_all_posts' => true])], | ||
['id' => 4, 'username' => 'acme2', 'email' => '[email protected]', 'is_email_confirmed' => 1], | ||
['id' => 3, 'username' => 'acme', 'email' => '[email protected]', 'is_email_confirmed' => 1], | ||
], | ||
'discussions' => [ | ||
['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 1, 'last_post_number' => 1, 'last_post_id' => 1], | ||
['id' => 2, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 2, 'comment_count' => 1, 'last_post_number' => 1, 'last_post_id' => 2], | ||
|
||
['id' => 33, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 33, 'comment_count' => 6, 'last_post_number' => 6, 'last_post_id' => 38], | ||
['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 1, 'last_post_number' => 2, 'last_post_id' => 2], | ||
], | ||
'posts' => [ | ||
['id' => 1, 'discussion_id' => 1, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 1], | ||
['id' => 2, 'discussion_id' => 2, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 1], | ||
|
||
['id' => 33, 'discussion_id' => 33, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 1], | ||
['id' => 34, 'discussion_id' => 33, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 2], | ||
['id' => 35, 'discussion_id' => 33, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 3], | ||
['id' => 36, 'discussion_id' => 33, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 4], | ||
['id' => 37, 'discussion_id' => 33, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 5], | ||
['id' => 38, 'discussion_id' => 33, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 6], | ||
['id' => 2, 'discussion_id' => 1, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 3, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 2], | ||
], | ||
'group_user' => [ | ||
['group_id' => Group::MEMBER_ID, 'user_id' => 2], | ||
], | ||
]); | ||
} | ||
|
@@ -65,17 +57,17 @@ public function approving_reply_sends_mention_notification() | |
->delete(); | ||
|
||
/** @var User $mainUser */ | ||
$mainUser = User::query()->find(2); | ||
$mainUser = User::query()->find(3); | ||
|
||
$this->assertEquals(0, $mainUser->getUnreadNotificationCount()); | ||
|
||
$response = $this->send( | ||
$this->request('POST', '/api/posts', [ | ||
'authenticatedAs' => 4, | ||
'authenticatedAs' => 2, | ||
'json' => [ | ||
'data' => [ | ||
'attributes' => [ | ||
'content' => 'reply with predetermined content for automated testing - too-obscure', | ||
'content' => '@"mainUser"#p2', | ||
], | ||
'relationships' => [ | ||
'discussion' => ['data' => ['id' => 1]], | ||
|
@@ -90,7 +82,7 @@ public function approving_reply_sends_mention_notification() | |
$json = json_decode($response->getBody()->getContents(), true); | ||
|
||
$this->send( | ||
$this->request('PATCH', '/api/posts'.$json['data']['id'], [ | ||
$this->request('PATCH', '/api/posts/'.$json['data']['id'], [ | ||
'authenticatedAs' => 1, | ||
'json' => [ | ||
'data' => [ | ||
|
@@ -101,5 +93,7 @@ public function approving_reply_sends_mention_notification() | |
] | ||
]) | ||
); | ||
|
||
$this->assertEquals(1, $mainUser->getUnreadNotificationCount()); | ||
} | ||
} |