|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace spec\NewTwitchApi\Resources; |
| 4 | + |
| 5 | +use GuzzleHttp\Client; |
| 6 | +use GuzzleHttp\Psr7\Request; |
| 7 | +use GuzzleHttp\Psr7\Response; |
| 8 | +use PhpSpec\ObjectBehavior; |
| 9 | +use Psr\Http\Message\ResponseInterface; |
| 10 | + |
| 11 | +class AnalyticsApiSpec extends ObjectBehavior |
| 12 | +{ |
| 13 | + function let(Client $guzzleClient) |
| 14 | + { |
| 15 | + $this->beConstructedWith($guzzleClient); |
| 16 | + } |
| 17 | + |
| 18 | + function it_should_get_extension_analytics(Client $guzzleClient, Response $response) |
| 19 | + { |
| 20 | + $guzzleClient->send(new Request('GET', 'analytics/extensions', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 21 | + $this->getExtensionAnalytics('TEST_TOKEN')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 22 | + } |
| 23 | + |
| 24 | + function it_should_get_extension_analytics_by_id(Client $guzzleClient, Response $response) |
| 25 | + { |
| 26 | + $guzzleClient->send(new Request('GET', 'analytics/extensions?extension_id=1', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 27 | + $this->getExtensionAnalytics('TEST_TOKEN', '1')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 28 | + } |
| 29 | + |
| 30 | + function it_should_get_extension_analytics_with_type(Client $guzzleClient, Response $response) |
| 31 | + { |
| 32 | + $guzzleClient->send(new Request('GET', 'analytics/extensions?type=overview_v1', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 33 | + $this->getExtensionAnalytics('TEST_TOKEN', null, 'overview_v1')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 34 | + } |
| 35 | + |
| 36 | + function it_should_get_extension_analytics_with_first(Client $guzzleClient, Response $response) |
| 37 | + { |
| 38 | + $guzzleClient->send(new Request('GET', 'analytics/extensions?first=100', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 39 | + $this->getExtensionAnalytics('TEST_TOKEN', null, null, 100)->shouldBeAnInstanceOf(ResponseInterface::class); |
| 40 | + } |
| 41 | + |
| 42 | + function it_should_get_extension_analytics_with_after(Client $guzzleClient, Response $response) |
| 43 | + { |
| 44 | + $guzzleClient->send(new Request('GET', 'analytics/extensions?after=abc', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 45 | + $this->getExtensionAnalytics('TEST_TOKEN', null, null, null, 'abc')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 46 | + } |
| 47 | + |
| 48 | + function it_should_get_extension_analytics_with_started_at(Client $guzzleClient, Response $response) |
| 49 | + { |
| 50 | + $guzzleClient->send(new Request('GET', 'analytics/extensions?started_at=2020-01-01T00:00:00Z', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 51 | + $this->getExtensionAnalytics('TEST_TOKEN', null, null, null, null, '2020-01-01T00:00:00Z')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 52 | + } |
| 53 | + |
| 54 | + function it_should_get_extension_analytics_with_ended_at(Client $guzzleClient, Response $response) |
| 55 | + { |
| 56 | + $guzzleClient->send(new Request('GET', 'analytics/extensions?ended_at=2020-01-01T00:00:00Z', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 57 | + $this->getExtensionAnalytics('TEST_TOKEN', null, null, null, null, null, '2020-01-01T00:00:00Z')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 58 | + } |
| 59 | + |
| 60 | + function it_should_get_game_analytics(Client $guzzleClient, Response $response) |
| 61 | + { |
| 62 | + $guzzleClient->send(new Request('GET', 'analytics/games', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 63 | + $this->getGameAnalytics('TEST_TOKEN')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 64 | + } |
| 65 | + |
| 66 | + function it_should_get_game_analytics_by_id(Client $guzzleClient, Response $response) |
| 67 | + { |
| 68 | + $guzzleClient->send(new Request('GET', 'analytics/games?game_id=1', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 69 | + $this->getGameAnalytics('TEST_TOKEN', '1')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 70 | + } |
| 71 | + |
| 72 | + function it_should_get_game_analytics_with_type(Client $guzzleClient, Response $response) |
| 73 | + { |
| 74 | + $guzzleClient->send(new Request('GET', 'analytics/games?type=overview_v1', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 75 | + $this->getGameAnalytics('TEST_TOKEN', null, 'overview_v1')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 76 | + } |
| 77 | + |
| 78 | + function it_should_get_game_analytics_with_first(Client $guzzleClient, Response $response) |
| 79 | + { |
| 80 | + $guzzleClient->send(new Request('GET', 'analytics/games?first=100', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 81 | + $this->getGameAnalytics('TEST_TOKEN', null, null, 100)->shouldBeAnInstanceOf(ResponseInterface::class); |
| 82 | + } |
| 83 | + |
| 84 | + function it_should_get_game_analytics_with_after(Client $guzzleClient, Response $response) |
| 85 | + { |
| 86 | + $guzzleClient->send(new Request('GET', 'analytics/games?after=abc', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 87 | + $this->getGameAnalytics('TEST_TOKEN', null, null, null, 'abc')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 88 | + } |
| 89 | + |
| 90 | + function it_should_get_game_analytics_with_started_at(Client $guzzleClient, Response $response) |
| 91 | + { |
| 92 | + $guzzleClient->send(new Request('GET', 'analytics/games?started_at=2020-01-01T00:00:00Z', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 93 | + $this->getGameAnalytics('TEST_TOKEN', null, null, null, null, '2020-01-01T00:00:00Z')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 94 | + } |
| 95 | + |
| 96 | + function it_should_get_game_analytics_with_ended_at(Client $guzzleClient, Response $response) |
| 97 | + { |
| 98 | + $guzzleClient->send(new Request('GET', 'analytics/games?ended_at=2020-01-01T00:00:00Z', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); |
| 99 | + $this->getGameAnalytics('TEST_TOKEN', null, null, null, null, null, '2020-01-01T00:00:00Z')->shouldBeAnInstanceOf(ResponseInterface::class); |
| 100 | + } |
| 101 | +} |
0 commit comments