|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Bitbucket\Tests\API\Repositories; |
| 4 | + |
| 5 | +use Bitbucket\Tests\API as Tests; |
| 6 | +use Bitbucket\API; |
| 7 | + |
| 8 | +class CommitsTest extends Tests\TestCase |
| 9 | +{ |
| 10 | + public function testGetAllRepositoryCommits() |
| 11 | + { |
| 12 | + $endpoint = 'repositories/gentle/eof/commits'; |
| 13 | + $expectedResult = $this->fakeResponse(array('dummy')); |
| 14 | + |
| 15 | + $client = $this->getHttpClientMock(); |
| 16 | + $client->expects($this->once()) |
| 17 | + ->method('post') |
| 18 | + ->with($endpoint) |
| 19 | + ->will($this->returnValue($expectedResult)); |
| 20 | + |
| 21 | + /** @var \Bitbucket\API\Repositories\Commits $commits */ |
| 22 | + $commits = $this->getClassMock('Bitbucket\API\Repositories\Commits', $client); |
| 23 | + $actual = $commits->all('gentle', 'eof', array('dummy')); |
| 24 | + |
| 25 | + $this->assertEquals($expectedResult, $actual); |
| 26 | + } |
| 27 | + |
| 28 | + public function testGetAllRepositoryCommitsFromSpecificBranch() |
| 29 | + { |
| 30 | + $endpoint = 'repositories/gentle/eof/commits/master'; |
| 31 | + $expectedResult = $this->fakeResponse(array('dummy', 'branch' => 'master')); |
| 32 | + |
| 33 | + $client = $this->getHttpClientMock(); |
| 34 | + $client->expects($this->once()) |
| 35 | + ->method('post') |
| 36 | + ->with($endpoint) |
| 37 | + ->will($this->returnValue($expectedResult)); |
| 38 | + |
| 39 | + /** @var \Bitbucket\API\Repositories\Commits $commits */ |
| 40 | + $commits = $this->getClassMock('Bitbucket\API\Repositories\Commits', $client); |
| 41 | + $actual = $commits->all('gentle', 'eof', array('dummy', 'branch' => 'master')); |
| 42 | + |
| 43 | + $this->assertEquals($expectedResult, $actual); |
| 44 | + } |
| 45 | + |
| 46 | + public function testGetSingleCommitInfo() |
| 47 | + { |
| 48 | + $endpoint = 'repositories/gentle/eof/commit/SHA'; |
| 49 | + $expectedResult = $this->fakeResponse(array('dummy')); |
| 50 | + |
| 51 | + $client = $this->getHttpClientMock(); |
| 52 | + $client->expects($this->once()) |
| 53 | + ->method('get') |
| 54 | + ->with($endpoint) |
| 55 | + ->will($this->returnValue($expectedResult)); |
| 56 | + |
| 57 | + /** @var \Bitbucket\API\Repositories\Commits $commits */ |
| 58 | + $commits = $this->getClassMock('Bitbucket\API\Repositories\Commits', $client); |
| 59 | + $actual = $commits->get('gentle', 'eof', 'SHA'); |
| 60 | + |
| 61 | + $this->assertEquals($expectedResult, $actual); |
| 62 | + } |
| 63 | +} |
0 commit comments