|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Tests\Api; |
| 4 | + |
| 5 | +use DateTime; |
| 6 | + |
| 7 | +class NotificationTest extends TestCase |
| 8 | +{ |
| 9 | + /** |
| 10 | + * @test |
| 11 | + */ |
| 12 | + public function shouldGetNotifications() |
| 13 | + { |
| 14 | + $parameters = array( |
| 15 | + 'all' => false, |
| 16 | + 'participating' => false, |
| 17 | + ); |
| 18 | + |
| 19 | + $api = $this->getApiMock(); |
| 20 | + $api->expects($this->once()) |
| 21 | + ->method('get') |
| 22 | + ->with('notifications', $parameters); |
| 23 | + |
| 24 | + $api->all(); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * @test |
| 29 | + */ |
| 30 | + public function shouldGetNotificationsSince() |
| 31 | + { |
| 32 | + $since = '2015-01-01 00:00:00'; |
| 33 | + |
| 34 | + $parameters = array( |
| 35 | + 'all' => false, |
| 36 | + 'participating' => false, |
| 37 | + 'since' => $since, |
| 38 | + ); |
| 39 | + |
| 40 | + $api = $this->getApiMock(); |
| 41 | + $api->expects($this->once()) |
| 42 | + ->method('get') |
| 43 | + ->with('notifications', $parameters); |
| 44 | + |
| 45 | + $api->all(false, false, $since); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @test |
| 50 | + */ |
| 51 | + public function shouldGetNotificationsIncludingAndParticipating() |
| 52 | + { |
| 53 | + $parameters = array( |
| 54 | + 'all' => true, |
| 55 | + 'participating' => true, |
| 56 | + ); |
| 57 | + |
| 58 | + $api = $this->getApiMock(); |
| 59 | + $api->expects($this->once()) |
| 60 | + ->method('get') |
| 61 | + ->with('notifications', $parameters); |
| 62 | + |
| 63 | + $api->all(true, true); |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * @test |
| 68 | + */ |
| 69 | + public function shouldMarkNotificationsAsRead() |
| 70 | + { |
| 71 | + $parameters = array(); |
| 72 | + |
| 73 | + $api = $this->getApiMock(); |
| 74 | + $api->expects($this->once()) |
| 75 | + ->method('put') |
| 76 | + ->with('notifications', $parameters); |
| 77 | + |
| 78 | + $api->markRead(); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * @test |
| 83 | + */ |
| 84 | + public function shouldMarkNotificationsAsReadForGivenDate() |
| 85 | + { |
| 86 | + $since = new DateTime('now'); |
| 87 | + |
| 88 | + $parameters = array( |
| 89 | + 'last_read_at' => $since->format(DateTime::ISO8601), |
| 90 | + ); |
| 91 | + |
| 92 | + $api = $this->getApiMock(); |
| 93 | + $api->expects($this->once()) |
| 94 | + ->method('put') |
| 95 | + ->with('notifications', $parameters); |
| 96 | + |
| 97 | + $api->markRead($since); |
| 98 | + } |
| 99 | + |
| 100 | + protected function getApiClass() |
| 101 | + { |
| 102 | + return 'Github\Api\Notification'; |
| 103 | + } |
| 104 | +} |
0 commit comments