Skip to content

Commit ba3f7de

Browse files
Steven Yungacrobat
authored andcommitted
Add support for "before" parameter on Notification API (#724)
* Add support for "before" parameter on Notification API add support for "before" paramaters on Notification API add NotificationTest@shouldGetNotificationsBefore * fix styling
1 parent 96b4ff0 commit ba3f7de

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/Github/Api/Notification.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Notification extends AbstractApi
2626
*
2727
* @return array array of notifications
2828
*/
29-
public function all($includingRead = false, $participating = false, DateTime $since = null)
29+
public function all($includingRead = false, $participating = false, DateTime $since = null, DateTime $before = null)
3030
{
3131
$parameters = [
3232
'all' => $includingRead,
@@ -37,6 +37,10 @@ public function all($includingRead = false, $participating = false, DateTime $si
3737
$parameters['since'] = $since->format(DateTime::ISO8601);
3838
}
3939

40+
if ($before !== null) {
41+
$parameters['before'] = $before->format(DateTime::ISO8601);
42+
}
43+
4044
return $this->get('/notifications', $parameters);
4145
}
4246

test/Github/Tests/Api/NotificationTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,27 @@ public function shouldGetNotificationsSince()
4545
$api->all(false, false, $since);
4646
}
4747

48+
/**
49+
* @test
50+
*/
51+
public function shouldGetNotificationsBefore()
52+
{
53+
$before = new DateTime('now');
54+
55+
$parameters = [
56+
'all' => false,
57+
'participating' => false,
58+
'before' => $before->format(DateTime::ISO8601),
59+
];
60+
61+
$api = $this->getApiMock();
62+
$api->expects($this->once())
63+
->method('get')
64+
->with('/notifications', $parameters);
65+
66+
$api->all(false, false, null, $before);
67+
}
68+
4869
/**
4970
* @test
5071
*/

0 commit comments

Comments
 (0)