Skip to content

Commit 1966086

Browse files
committed
Resolve Tests, Remove Webhooks Api Spec
1 parent 4a28c46 commit 1966086

File tree

3 files changed

+19
-137
lines changed

3 files changed

+19
-137
lines changed

spec/NewTwitchApi/HelixGuzzleClientSpec.php

+13-10
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22

33
namespace spec\NewTwitchApi;
44

5-
use GuzzleHttp\Psr7\Uri;
5+
use NewTwitchApi\HelixGuzzleClient;
66
use PhpSpec\ObjectBehavior;
77

88
class HelixGuzzleClientSpec extends ObjectBehavior
99
{
10+
function let(HelixGuzzleClient $guzzleClient)
11+
{
12+
$this->beConstructedWith('TEST_CLIENT_ID');
13+
}
14+
1015
function it_should_have_correct_base_uri()
1116
{
12-
$this->beConstructedThrough('getClient', ['client-id']);
13-
$this->shouldHaveType('\GuzzleHttp\Client');
17+
$this->shouldHaveType('\NewTwitchApi\HelixGuzzleClient');
1418

1519
/** @var Uri $uri */
1620
$uri = $this->getConfig('base_uri');
@@ -21,22 +25,21 @@ function it_should_have_correct_base_uri()
2125

2226
function it_should_have_client_id_header()
2327
{
24-
$this->beConstructedThrough('getClient', ['client-id']);
25-
$this->shouldHaveType('\GuzzleHttp\Client');
26-
$this->getConfig('headers')->shouldHaveKeyWithValue('Client-ID', 'client-id');
28+
$this->shouldHaveType('\NewTwitchApi\HelixGuzzleClient');
29+
$this->getConfig('headers')->shouldHaveKeyWithValue('Client-ID', 'TEST_CLIENT_ID');
2730
}
2831

2932
function it_should_have_json_content_type_header()
3033
{
31-
$this->beConstructedThrough('getClient', ['client-id']);
32-
$this->shouldHaveType('\GuzzleHttp\Client');
34+
35+
$this->shouldHaveType('\NewTwitchApi\HelixGuzzleClient');
3336
$this->getConfig('headers')->shouldHaveKeyWithValue('Content-Type', 'application/json');
3437
}
3538

3639
function it_should_have_passed_in_config_params_instead_of_defaults()
3740
{
38-
$this->beConstructedThrough('getClient', ['client-id', ['base_uri' => 'https://different.url']]);
39-
$this->shouldHaveType('\GuzzleHttp\Client');
41+
$this->beConstructedWith('TEST_CLIENT_ID', ['base_uri' => 'https://different.url']);
42+
$this->shouldHaveType('\NewTwitchApi\HelixGuzzleClient');
4043
$this->getConfig('base_uri')->getHost()->shouldBe('different.url');
4144
}
4245
}

spec/NewTwitchApi/Webhooks/WebhooksSubscriptionApiSpec.php

-121
This file was deleted.

src/NewTwitchApi/HelixGuzzleClient.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ class HelixGuzzleClient
1313

1414
public function __construct(string $clientId, array $config = [], string $baseUri = null)
1515
{
16-
if ($baseUri === null) {
17-
$baseUri = self::BASE_URI;
18-
}
16+
if($baseUri == null) {
17+
$baseUri = self::BASE_URI;
18+
}
1919

2020
$headers = [
2121
'Client-ID' => $clientId,
22-
'Accept' => 'application/json',
22+
'Content-Type' => 'application/json',
2323
];
2424

2525
$client_config = [
@@ -36,9 +36,9 @@ public function __construct(string $clientId, array $config = [], string $baseUr
3636
$this->client = new Client($client_config);
3737
}
3838

39-
public static function getClient(string $clientId, array $config = []): Client
39+
public function getConfig($option = null)
4040
{
41-
return $this->client;
41+
return $this->client->getConfig($option);
4242
}
4343

4444
public function send($request)

0 commit comments

Comments
 (0)