|
| 1 | +<?php |
| 2 | + |
| 3 | +use Github\Tests\Api\TestCase; |
| 4 | + |
| 5 | +class TrafficTest extends TestCase |
| 6 | +{ |
| 7 | + |
| 8 | + /** |
| 9 | + * @test |
| 10 | + */ |
| 11 | + public function shouldgetReferers() |
| 12 | + { |
| 13 | + $expectedValue = json_encode(["referrer" => "github.com","count" => 112,"uniques" => 15]); |
| 14 | + |
| 15 | + $api = $this->getApiMock(); |
| 16 | + |
| 17 | + $api->expects($this->once()) |
| 18 | + ->method('get') |
| 19 | + ->with('/repos/knplabs/php-github-api/traffic/popular/referrers') |
| 20 | + ->will($this->returnValue($expectedValue)); |
| 21 | + |
| 22 | + $result = $api->referers('knplabs', 'php-github-api'); |
| 23 | + |
| 24 | + $this->assertEquals($expectedValue, $result); |
| 25 | + } |
| 26 | + |
| 27 | + public function shouldgetPaths() |
| 28 | + { |
| 29 | + $expectedValue = json_encode(["path" => "/knplabs/php-github-api","title" => "KnpLabs/php-github-api: A simple PHP GitHub API client, Object Oriented, tested and documented. For 5.5+.","count" => 203,"uniques" => 54]); |
| 30 | + |
| 31 | + $api = $this->getApiMock(); |
| 32 | + |
| 33 | + $api->expects($this->once()) |
| 34 | + ->method('get') |
| 35 | + ->with('/repos/knplabs/php-github-api/traffic/popular/paths') |
| 36 | + ->will($this->returnValue($expectedValue)); |
| 37 | + |
| 38 | + $result = $api->paths('knplabs', 'php-github-api'); |
| 39 | + |
| 40 | + $this->assertEquals($expectedValue, $result); |
| 41 | + } |
| 42 | + |
| 43 | + public function shouldgetViews() |
| 44 | + { |
| 45 | + $expectedValue = json_encode(["count" => 813,"uniques" => 61,"views" => [["timestamp" => "2017-03-12T00:00:00Z","count" => 40,"uniques" => 3]]]); |
| 46 | + |
| 47 | + $api = $this->getApiMock(); |
| 48 | + |
| 49 | + $api->expects($this->once()) |
| 50 | + ->method('get') |
| 51 | + ->with('/repos/knplabs/php-github-api/traffic/views?per=day') |
| 52 | + ->will($this->returnValue($expectedValue)); |
| 53 | + |
| 54 | + $result = $api->views('knplabs', 'php-github-api'); |
| 55 | + |
| 56 | + $this->assertEquals($expectedValue, $result); |
| 57 | + } |
| 58 | + |
| 59 | + public function shouldgetClones() |
| 60 | + { |
| 61 | + $expectedValue = json_encode(["count" => 813,"uniques" => 61,"clones" => [["timestamp" => "2017-03-12T00:00:00Z","count" => 14,"uniques" => 8]]]); |
| 62 | + |
| 63 | + $api = $this->getApiMock(); |
| 64 | + |
| 65 | + $api->expects($this->once()) |
| 66 | + ->method('get') |
| 67 | + ->with('/repos/knplabs/php-github-api/traffic/clones?per=day') |
| 68 | + ->will($this->returnValue($expectedValue)); |
| 69 | + |
| 70 | + $result = $api->clones('knplabs', 'php-github-api'); |
| 71 | + |
| 72 | + $this->assertEquals($expectedValue, $result); |
| 73 | + } |
| 74 | + |
| 75 | + protected function getApiClass() |
| 76 | + { |
| 77 | + return \Github\Api\Repository\Traffic::class; |
| 78 | + } |
| 79 | +} |
0 commit comments