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