-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from nicklaw5/v7.0.1
Finish Endpoint and Testing Coverage
- Loading branch information
Showing
10 changed files
with
246 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace spec\TwitchApi\Resources; | ||
|
||
use GuzzleHttp\Psr7\Request; | ||
use GuzzleHttp\Psr7\Response; | ||
use TwitchApi\RequestGenerator; | ||
use TwitchApi\HelixGuzzleClient; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class ClipsApiSpec extends ObjectBehavior | ||
{ | ||
function let(HelixGuzzleClient $guzzleClient, RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$this->beConstructedWith($guzzleClient, $requestGenerator); | ||
$guzzleClient->send($request)->willReturn($response); | ||
} | ||
|
||
function it_should_get_clips_by_broadcaster_id(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'clips', 'TEST_TOKEN', [['key' => 'broadcaster_id', 'value' => '123']], [])->willReturn($request); | ||
$this->getClips('TEST_TOKEN', '123')->shouldBe($response); | ||
} | ||
|
||
function it_should_get_clips_by_broadcaster_id_with_helper_function(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'clips', 'TEST_TOKEN', [['key' => 'broadcaster_id', 'value' => '123']], [])->willReturn($request); | ||
$this->getClipsByBroadcasterId('TEST_TOKEN', '123')->shouldBe($response); | ||
} | ||
|
||
function it_should_get_clips_by_game_id(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'clips', 'TEST_TOKEN', [['key' => 'game_id', 'value' => '123']], [])->willReturn($request); | ||
$this->getClips('TEST_TOKEN', null, '123')->shouldBe($response); | ||
} | ||
|
||
function it_should_get_clips_by_game_id_with_helper_function(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'clips', 'TEST_TOKEN', [['key' => 'game_id', 'value' => '123']], [])->willReturn($request); | ||
$this->getClipsByGameId('TEST_TOKEN', '123')->shouldBe($response); | ||
} | ||
|
||
function it_should_get_one_clip_by_id(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'clips', 'TEST_TOKEN', [['key' => 'id', 'value' => '123']], [])->willReturn($request); | ||
$this->getClips('TEST_TOKEN', null, null, '123')->shouldBe($response); | ||
} | ||
|
||
function it_should_get_one_clip_by_id_with_helper_function(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'clips', 'TEST_TOKEN', [['key' => 'id', 'value' => '123']], [])->willReturn($request); | ||
$this->getClipsByIds('TEST_TOKEN', '123')->shouldBe($response); | ||
} | ||
|
||
function it_should_get_multiple_clips_by_id(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'clips', 'TEST_TOKEN', [['key' => 'id', 'value' => '123,456']], [])->willReturn($request); | ||
$this->getClips('TEST_TOKEN', null, null, '123,456')->shouldBe($response); | ||
} | ||
|
||
function it_should_get_multiple_clips_by_id_with_helper_function(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'clips', 'TEST_TOKEN', [['key' => 'id', 'value' => '123,456']], [])->willReturn($request); | ||
$this->getClipsByIds('TEST_TOKEN', '123,456')->shouldBe($response); | ||
} | ||
|
||
function it_should_get_clips_with_opts(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'clips', 'TEST_TOKEN', [['key' => 'broadcaster_id', 'value' => '123'], ['key' => 'first', 'value' => '10'], ['key' => 'before', 'value' => 'abc'], ['key' => 'after', 'value' => 'def'], ['key' => 'started_at', 'value' => '2018-10-12T07:20:50.52Z'], ['key' => 'ended_at', 'value' => '2019-10-12T07:20:50.52Z']], [])->willReturn($request); | ||
$this->getClips('TEST_TOKEN', '123', null, null, 10, 'abc', 'def', '2018-10-12T07:20:50.52Z', '2019-10-12T07:20:50.52Z')->shouldBe($response); | ||
} | ||
|
||
function it_should_create_a_clip(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('POST', 'clips', 'TEST_TOKEN', [['key' => 'broadcaster_id', 'value' => '123'], ['key' => 'has_delay', 'value' => 'true']], [])->willReturn($request); | ||
$this->createClip('TEST_TOKEN', '123', true)->shouldBe($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace spec\TwitchApi\Resources; | ||
|
||
use GuzzleHttp\Psr7\Request; | ||
use GuzzleHttp\Psr7\Response; | ||
use TwitchApi\RequestGenerator; | ||
use TwitchApi\HelixGuzzleClient; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class SearchApiSpec extends ObjectBehavior | ||
{ | ||
function let(HelixGuzzleClient $guzzleClient, RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$this->beConstructedWith($guzzleClient, $requestGenerator); | ||
$guzzleClient->send($request)->willReturn($response); | ||
} | ||
|
||
function it_should_search_categories(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'search/categories', 'TEST_TOKEN', [['key' => 'query', 'value' => 'test']], [])->willReturn($request); | ||
$this->searchCategories('TEST_TOKEN', 'test')->shouldBe($response); | ||
} | ||
|
||
function it_should_search_categories_with_opts(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'search/categories', 'TEST_TOKEN', [['key' => 'query', 'value' => 'test'], ['key' => 'first', 'value' => 100], ['key' => 'after', 'value' => 'abc']], [])->willReturn($request); | ||
$this->searchCategories('TEST_TOKEN', 'test', 100, 'abc')->shouldBe($response); | ||
} | ||
|
||
function it_should_search_channels(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'search/channels', 'TEST_TOKEN', [['key' => 'query', 'value' => 'test']], [])->willReturn($request); | ||
$this->searchChannels('TEST_TOKEN', 'test')->shouldBe($response); | ||
} | ||
|
||
function it_should_search_channels_with_opts(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'search/channels', 'TEST_TOKEN', [['key' => 'query', 'value' => 'test'], ['key' => 'live_only', 'value' => true], ['key' => 'first', 'value' => 100], ['key' => 'after', 'value' => 'abc']], [])->willReturn($request); | ||
$this->searchChannels('TEST_TOKEN', 'test', true, 100, 'abc')->shouldBe($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters