From b4114cdde9d8fb4e2bc1fb6d8a81b54e0979b1c3 Mon Sep 17 00:00:00 2001 From: Steven Yung Date: Sun, 5 Aug 2018 14:09:55 +0200 Subject: [PATCH 1/2] Add support for "before" parameter on Notification API add support for "before" paramaters on Notification API add NotificationTest@shouldGetNotificationsBefore --- lib/Github/Api/Notification.php | 7 ++++++- test/Github/Tests/Api/NotificationTest.php | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/Github/Api/Notification.php b/lib/Github/Api/Notification.php index 1759f26132c..cde2144db2c 100644 --- a/lib/Github/Api/Notification.php +++ b/lib/Github/Api/Notification.php @@ -26,7 +26,7 @@ class Notification extends AbstractApi * * @return array array of notifications */ - public function all($includingRead = false, $participating = false, DateTime $since = null) + public function all($includingRead = false, $participating = false, DateTime $since = null, DateTime $before = null) { $parameters = [ 'all' => $includingRead, @@ -37,6 +37,11 @@ public function all($includingRead = false, $participating = false, DateTime $si $parameters['since'] = $since->format(DateTime::ISO8601); } + if ($before !== null) { + $parameters['before'] = $before->format(DateTime::ISO8601); + } + + return $this->get('/notifications', $parameters); } diff --git a/test/Github/Tests/Api/NotificationTest.php b/test/Github/Tests/Api/NotificationTest.php index e34dc171ced..7ef3e64ba45 100644 --- a/test/Github/Tests/Api/NotificationTest.php +++ b/test/Github/Tests/Api/NotificationTest.php @@ -45,6 +45,27 @@ public function shouldGetNotificationsSince() $api->all(false, false, $since); } + /** + * @test + */ + public function shouldGetNotificationsBefore() + { + $before = new DateTime('now'); + + $parameters = [ + 'all' => false, + 'participating' => false, + 'before' => $before->format(DateTime::ISO8601), + ]; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('/notifications', $parameters); + + $api->all(false, false, null, $before); + } + /** * @test */ From 31f0ade692cf4cb8ae733d8213d5c1aa2e3fbeb0 Mon Sep 17 00:00:00 2001 From: Steven Yung Date: Sun, 5 Aug 2018 15:31:33 +0200 Subject: [PATCH 2/2] fix styling --- lib/Github/Api/Notification.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Github/Api/Notification.php b/lib/Github/Api/Notification.php index cde2144db2c..0d73d6076c7 100644 --- a/lib/Github/Api/Notification.php +++ b/lib/Github/Api/Notification.php @@ -41,7 +41,6 @@ public function all($includingRead = false, $participating = false, DateTime $si $parameters['before'] = $before->format(DateTime::ISO8601); } - return $this->get('/notifications', $parameters); }