|
6 | 6 |
|
7 | 7 | class IssueTest extends ApiTestCase |
8 | 8 | { |
9 | | - public function testGetList() |
| 9 | + /** |
| 10 | + * @test |
| 11 | + */ |
| 12 | + public function shouldBuildValidQueryForGetList() |
10 | 13 | { |
11 | 14 | $api = $this->getApiMock(); |
12 | 15 |
|
13 | 16 | $api->expects($this->once()) |
14 | 17 | ->method('get') |
15 | | - ->with('issues/list/ornicar/php-github-api/open'); |
| 18 | + ->with('repos/ornicar/php-github-api/issues?state=open'); |
16 | 19 |
|
17 | 20 | $api->getList('ornicar', 'php-github-api', 'open'); |
18 | 21 | } |
19 | 22 |
|
| 23 | + /** |
| 24 | + * @test |
| 25 | + */ |
| 26 | + public function shouldBuildValidQueryForGetListWithAdditionalParameters() |
| 27 | + { |
| 28 | + $api = $this->getApiMock(); |
| 29 | + |
| 30 | + $api->expects($this->once()) |
| 31 | + ->method('get') |
| 32 | + ->with('repos/ornicar/php-github-api/issues?milestone=%2A&assignee=l3l0&mentioned=l3l0&labels=bug%2C%40high&sort=created&direction=asc&state=open'); |
| 33 | + |
| 34 | + $api->getList('ornicar', 'php-github-api', 'open', array( |
| 35 | + 'milestone' => '*', |
| 36 | + 'assignee' => 'l3l0', |
| 37 | + 'mentioned' => 'l3l0', |
| 38 | + 'labels' => 'bug,@high', |
| 39 | + 'sort' => 'created', |
| 40 | + 'direction' => 'asc' |
| 41 | + )); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * @test |
| 46 | + */ |
| 47 | + public function shouldBuildValidQueryForShow() |
| 48 | + { |
| 49 | + $api = $this->getApiMock(); |
| 50 | + |
| 51 | + $api->expects($this->once()) |
| 52 | + ->method('get') |
| 53 | + ->with('repos/ornicar/php-github-api/issues/14'); |
| 54 | + |
| 55 | + $api->show('ornicar', 'php-github-api', 14); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * @test |
| 60 | + */ |
| 61 | + public function shouldBuildValidQueryForOpen() |
| 62 | + { |
| 63 | + $api = $this->getApiMock(); |
| 64 | + |
| 65 | + $api->expects($this->once()) |
| 66 | + ->method('post') |
| 67 | + ->with('repos/ornicar/php-github-api/issues', array( |
| 68 | + 'title' => 'some title', |
| 69 | + 'body' => 'some body' |
| 70 | + )); |
| 71 | + |
| 72 | + $api->open('ornicar', 'php-github-api', 'some title', 'some body'); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * @test |
| 77 | + */ |
| 78 | + public function shouldBuildValidQueryForClose() |
| 79 | + { |
| 80 | + $api = $this->getApiMock(); |
| 81 | + |
| 82 | + $api->expects($this->once()) |
| 83 | + ->method('patch') |
| 84 | + ->with('repos/ornicar/php-github-api/issues/14', array( |
| 85 | + 'state' => 'closed', |
| 86 | + )); |
| 87 | + |
| 88 | + $api->close('ornicar', 'php-github-api', 14); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * @test |
| 93 | + */ |
| 94 | + public function shouldBuildValidQueryForReOpen() |
| 95 | + { |
| 96 | + $api = $this->getApiMock(); |
| 97 | + |
| 98 | + $api->expects($this->once()) |
| 99 | + ->method('patch') |
| 100 | + ->with('repos/ornicar/php-github-api/issues/14', array( |
| 101 | + 'state' => 'open', |
| 102 | + )); |
| 103 | + |
| 104 | + $api->reOpen('ornicar', 'php-github-api', 14); |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * @test |
| 109 | + */ |
| 110 | + public function shouldBuildValidQueryForGetComments() |
| 111 | + { |
| 112 | + $api = $this->getApiMock(); |
| 113 | + |
| 114 | + $api->expects($this->once()) |
| 115 | + ->method('get') |
| 116 | + ->with('repos/ornicar/php-github-api/issues/14/comments'); |
| 117 | + |
| 118 | + $api->getComments('ornicar', 'php-github-api', 14); |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * @test |
| 123 | + */ |
| 124 | + public function shouldBuildValidQueryForGetComment() |
| 125 | + { |
| 126 | + $api = $this->getApiMock(); |
| 127 | + |
| 128 | + $api->expects($this->once()) |
| 129 | + ->method('get') |
| 130 | + ->with('repos/ornicar/php-github-api/issues/comments/666'); |
| 131 | + |
| 132 | + $api->getComment('ornicar', 'php-github-api', 666); |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * @test |
| 137 | + */ |
| 138 | + public function shouldBuildValidQueryForAddComment() |
| 139 | + { |
| 140 | + $api = $this->getApiMock(); |
| 141 | + |
| 142 | + $api->expects($this->once()) |
| 143 | + ->method('post') |
| 144 | + ->with('repos/ornicar/php-github-api/issues/14/comments', array( |
| 145 | + 'body' => 'some body' |
| 146 | + )); |
| 147 | + |
| 148 | + $api->addComment('ornicar', 'php-github-api', 14, 'some body'); |
| 149 | + } |
| 150 | + |
| 151 | + /** |
| 152 | + * @test |
| 153 | + */ |
| 154 | + public function shouldBuildValidQueryForGetLabels() |
| 155 | + { |
| 156 | + $api = $this->getApiMock(); |
| 157 | + |
| 158 | + $api->expects($this->once()) |
| 159 | + ->method('get') |
| 160 | + ->with('repos/ornicar/php-github-api/labels'); |
| 161 | + |
| 162 | + $api->getLabels('ornicar', 'php-github-api'); |
| 163 | + } |
| 164 | + |
| 165 | + /** |
| 166 | + * @test |
| 167 | + */ |
| 168 | + public function shouldBuildValidQueryForGetLabel() |
| 169 | + { |
| 170 | + $api = $this->getApiMock(); |
| 171 | + |
| 172 | + $api->expects($this->once()) |
| 173 | + ->method('get') |
| 174 | + ->with('repos/ornicar/php-github-api/labels/my-label'); |
| 175 | + |
| 176 | + $api->getLabel('ornicar', 'php-github-api', 'my-label'); |
| 177 | + } |
| 178 | + |
| 179 | + /** |
| 180 | + * @test |
| 181 | + */ |
| 182 | + public function shouldBuildValidQueryForAddLabel() |
| 183 | + { |
| 184 | + $api = $this->getApiMock(); |
| 185 | + |
| 186 | + $api->expects($this->once()) |
| 187 | + ->method('post') |
| 188 | + ->with('repos/ornicar/php-github-api/labels', array( |
| 189 | + 'name' => 'my-label', |
| 190 | + 'color' => 'FFFFFF' |
| 191 | + )); |
| 192 | + |
| 193 | + $api->addLabel('ornicar', 'php-github-api', 'my-label', 'FFFFFF'); |
| 194 | + } |
| 195 | + |
| 196 | + /** |
| 197 | + * @test |
| 198 | + */ |
| 199 | + public function shouldBuildValidQueryForRemoveLabel() |
| 200 | + { |
| 201 | + $api = $this->getApiMock(); |
| 202 | + |
| 203 | + $api->expects($this->once()) |
| 204 | + ->method('delete') |
| 205 | + ->with('repos/ornicar/php-github-api/labels/my-label'); |
| 206 | + |
| 207 | + $api->removeLabel('ornicar', 'php-github-api', 'my-label'); |
| 208 | + } |
| 209 | + |
20 | 210 | protected function getApiClass() |
21 | 211 | { |
22 | 212 | return 'Github\Api\Issue'; |
|
0 commit comments