|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Tests\Api; |
| 4 | + |
| 5 | +class AuthorizationsTest extends TestCase |
| 6 | +{ |
| 7 | + /** |
| 8 | + * @test |
| 9 | + */ |
| 10 | + public function shouldGetAllAuthorizations() |
| 11 | + { |
| 12 | + $expectedArray = array(array('id' => '123')); |
| 13 | + |
| 14 | + $api = $this->getApiMock(); |
| 15 | + $api->expects($this->once()) |
| 16 | + ->method('get') |
| 17 | + ->with('authorizations') |
| 18 | + ->will($this->returnValue($expectedArray)); |
| 19 | + |
| 20 | + $this->assertEquals($expectedArray, $api->all()); |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * @test |
| 25 | + */ |
| 26 | + public function shouldShowAuthorization() |
| 27 | + { |
| 28 | + $id = 123; |
| 29 | + $expectedArray = array('id' => $id); |
| 30 | + |
| 31 | + $api = $this->getApiMock(); |
| 32 | + $api->expects($this->once()) |
| 33 | + ->method('get') |
| 34 | + ->with('authorizations/'.$id) |
| 35 | + ->will($this->returnValue($expectedArray)); |
| 36 | + |
| 37 | + $this->assertEquals($expectedArray, $api->show($id)); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * @test |
| 42 | + */ |
| 43 | + public function shouldCheckAuthorization() |
| 44 | + { |
| 45 | + $id = 123; |
| 46 | + $token = 'abc'; |
| 47 | + $expectedArray = array('id' => $id); |
| 48 | + |
| 49 | + $api = $this->getApiMock(); |
| 50 | + $api->expects($this->once()) |
| 51 | + ->method('get') |
| 52 | + ->with('authorizations/'.$id.'/tokens/'.$token) |
| 53 | + ->will($this->returnValue($expectedArray)); |
| 54 | + |
| 55 | + $this->assertEquals($expectedArray, $api->check($id, $token)); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * @test |
| 60 | + */ |
| 61 | + public function shouldAuthorization() |
| 62 | + { |
| 63 | + $input = array( |
| 64 | + 'note' => '', |
| 65 | + ); |
| 66 | + |
| 67 | + $api = $this->getApiMock(); |
| 68 | + $api->expects($this->once()) |
| 69 | + ->method('post') |
| 70 | + ->with('authorizations', $input); |
| 71 | + |
| 72 | + $api->create($input); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * @test |
| 77 | + */ |
| 78 | + public function shouldUpdateAuthorization() |
| 79 | + { |
| 80 | + $id = 123; |
| 81 | + $input = array( |
| 82 | + 'note' => '', |
| 83 | + ); |
| 84 | + |
| 85 | + $api = $this->getApiMock(); |
| 86 | + $api->expects($this->once()) |
| 87 | + ->method('patch') |
| 88 | + ->with('authorizations/'.$id, $input); |
| 89 | + |
| 90 | + $api->update($id, $input); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * @test |
| 95 | + */ |
| 96 | + public function shouldDeleteAuthorization() |
| 97 | + { |
| 98 | + $id = 123; |
| 99 | + $api = $this->getApiMock(); |
| 100 | + $api->expects($this->once()) |
| 101 | + ->method('delete') |
| 102 | + ->with('authorizations/'.$id); |
| 103 | + |
| 104 | + $api->remove($id); |
| 105 | + } |
| 106 | + |
| 107 | + protected function getApiClass() |
| 108 | + { |
| 109 | + return 'Github\Api\Authorizations'; |
| 110 | + } |
| 111 | +} |
0 commit comments