|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * This file is part of the php-github-api package. |
| 4 | + * |
| 5 | + * For the full copyright and license information, please view the LICENSE |
| 6 | + * file that was distributed with this source code. |
| 7 | + */ |
| 8 | + |
| 9 | +namespace Github\Tests\Api\Enterprise; |
| 10 | + |
| 11 | +use Github\Tests\Api\TestCase; |
| 12 | + |
| 13 | +class StatsTest extends TestCase |
| 14 | +{ |
| 15 | + /** |
| 16 | + * @test |
| 17 | + */ |
| 18 | + public function shouldShowStats() |
| 19 | + { |
| 20 | + $expectedJson = $this->getJson(); |
| 21 | + $expectedArray = json_encode($expectedJson); |
| 22 | + |
| 23 | + $api = $this->getApiMock(); |
| 24 | + $api->expects($this->once()) |
| 25 | + ->method('get') |
| 26 | + ->with('enterprise/stats/all') |
| 27 | + ->will($this->returnValue($expectedArray)); |
| 28 | + |
| 29 | + $this->assertEquals($expectedArray, $api->show('all')); |
| 30 | + } |
| 31 | + |
| 32 | + protected function getJson() |
| 33 | + { |
| 34 | + return '{"repos":{"total_repos": 212, "root_repos": 194, "fork_repos": 18, "org_repos": 51, |
| 35 | + "total_pushes": 3082, "total_wikis": 15 }, "hooks": { "total_hooks": 27, "active_hooks": 23, |
| 36 | + "inactive_hooks": 4 }, "pages": { "total_pages": 36 }, "orgs": { "total_orgs": 33, "disabled_orgs": 0, |
| 37 | + "total_teams": 60, "total_team_members": 314 }, "users": { "total_users": 254, "admin_users": 45, |
| 38 | + "suspended_users": 21 }, "pulls": { "total_pulls": 86, "merged_pulls": 60, "mergeable_pulls": 21, |
| 39 | + "unmergeable_pulls": 3 }, "issues": { "total_issues": 179, "open_issues": 83, "closed_issues": 96 }, |
| 40 | + "milestones": { "total_milestones": 7, "open_milestones": 6, "closed_milestones": 1 }, "gists": |
| 41 | + { "total_gists": 178, "private_gists": 151, "public_gists": 25 }, "comments": { "total_commit_comments": 6, |
| 42 | + "total_gist_comments": 28, "total_issue_comments": 366, "total_pull_request_comments": 30 } }'; |
| 43 | + } |
| 44 | + |
| 45 | + protected function getApiClass() |
| 46 | + { |
| 47 | + return 'Github\Api\Enterprise\Stats'; |
| 48 | + } |
| 49 | +} |
0 commit comments