Skip to content

Commit 240a5cd

Browse files
committed
Do not read the notification we just inserted
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent 9c45cf5 commit 240a5cd

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

lib/App.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public function notify(INotification $notification): void {
5454
$notificationId = $this->handler->add($notification);
5555

5656
try {
57-
$notificationToPush = $this->handler->getById($notificationId, $notification->getUser());
58-
$this->push->pushToDevice($notificationId, $notificationToPush);
57+
$this->push->pushToDevice($notificationId, $notification);
5958
} catch (NotificationNotFoundException $e) {
6059
throw new \InvalidArgumentException('Error while preparing push notification');
6160
}

tests/Unit/AppTest.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,21 @@ protected function setUp(): void {
5353

5454
public function dataNotify() {
5555
return [
56-
[23, 'user1'],
57-
[42, 'user2'],
56+
[23],
57+
[42],
5858
];
5959
}
6060

6161
/**
6262
* @dataProvider dataNotify
6363
*
6464
* @param int $id
65-
* @param string $user
6665
*/
67-
public function testNotify($id, $user) {
68-
$this->notification->expects($this->once())
69-
->method('getUser')
70-
->willReturn($user);
71-
66+
public function testNotify($id) {
7267
$this->handler->expects($this->once())
7368
->method('add')
7469
->with($this->notification)
7570
->willReturn($id);
76-
$this->handler->expects($this->once())
77-
->method('getById')
78-
->with($id, $user)
79-
->willReturn($this->notification);
8071
$this->push->expects($this->once())
8172
->method('pushToDevice')
8273
->with($id, $this->notification);

0 commit comments

Comments
 (0)