|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Tests\Api; |
| 4 | + |
| 5 | +use Github\Tests\Api\TestCase; |
| 6 | + |
| 7 | +/** |
| 8 | + * CurrentUser watchers api test case |
| 9 | + * |
| 10 | + * @author Joseph Bielawski <stloyd@gmail.com> |
| 11 | + */ |
| 12 | +class WatchersTest extends TestCase |
| 13 | +{ |
| 14 | + /** |
| 15 | + * @test |
| 16 | + */ |
| 17 | + public function shouldGetWatchers() |
| 18 | + { |
| 19 | + $expectedValue = array( |
| 20 | + array('name' => 'l3l0/test'), |
| 21 | + array('name' => 'cordoval/test') |
| 22 | + ); |
| 23 | + |
| 24 | + $api = $this->getApiMock(); |
| 25 | + $api->expects($this->once()) |
| 26 | + ->method('get') |
| 27 | + ->with('user/watched') |
| 28 | + ->will($this->returnValue($expectedValue)); |
| 29 | + |
| 30 | + $this->assertEquals($expectedValue, $api->all()); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @test |
| 35 | + */ |
| 36 | + public function shouldCheckWatcher() |
| 37 | + { |
| 38 | + $api = $this->getApiMock(); |
| 39 | + $api->expects($this->once()) |
| 40 | + ->method('get') |
| 41 | + ->with('user/watched/l3l0/test') |
| 42 | + ->will($this->returnValue(null)); |
| 43 | + |
| 44 | + $this->assertNull($api->check('l3l0', 'test')); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @test |
| 49 | + */ |
| 50 | + public function shouldWatchUser() |
| 51 | + { |
| 52 | + $api = $this->getApiMock(); |
| 53 | + $api->expects($this->once()) |
| 54 | + ->method('put') |
| 55 | + ->with('user/watched/l3l0/test') |
| 56 | + ->will($this->returnValue(null)); |
| 57 | + |
| 58 | + $this->assertNull($api->watch('l3l0', 'test')); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * @test |
| 63 | + */ |
| 64 | + public function shouldUnwatchUser() |
| 65 | + { |
| 66 | + $api = $this->getApiMock(); |
| 67 | + $api->expects($this->once()) |
| 68 | + ->method('delete') |
| 69 | + ->with('user/watched/l3l0/test') |
| 70 | + ->will($this->returnValue(null)); |
| 71 | + |
| 72 | + $this->assertNull($api->unwatch('l3l0', 'test')); |
| 73 | + } |
| 74 | + |
| 75 | + protected function getApiClass() |
| 76 | + { |
| 77 | + return 'Github\Api\CurrentUser\Watchers'; |
| 78 | + } |
| 79 | +} |
0 commit comments