Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 224faeb

Browse files
committed
🚿
1 parent d5f2526 commit 224faeb

File tree

5 files changed

+13
-19
lines changed

5 files changed

+13
-19
lines changed

tests/API/OAuthAPITestAbstract.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
use Psr\Http\Client\ClientInterface;
1919
use Psr\Log\LoggerInterface;
2020

21-
use const DIRECTORY_SEPARATOR;
22-
2321
abstract class OAuthAPITestAbstract extends ProviderTestAbstract{
2422

2523
protected string $ENV;

tests/Providers/OAuth1ProviderTestAbstract.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use chillerlan\OAuth\Core\{AccessToken, OAuth1Interface, ProviderException};
1414
use chillerlan\HTTP\Utils\Query;
1515

16-
use function chillerlan\HTTP\Utils\get_json;
1716
use function parse_url;
1817

1918
use const PHP_URL_QUERY;
@@ -143,7 +142,7 @@ public function testRequest():void{
143142
$token = new AccessToken(['accessTokenSecret' => 'test_token']);
144143
$this->storage->storeAccessToken($this->provider->serviceName, $token);
145144

146-
$this::assertSame('such data! much wow!', get_json($this->provider->request('/request'))->data);
145+
$this::assertSame('such data! much wow!', $this->responseJson($this->provider->request('/request'))->data);
147146

148147
// coverage, @todo
149148
$this->provider

tests/Providers/OAuth2ProviderTestAbstract.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
use chillerlan\OAuth\OAuthException;
1515
use chillerlan\HTTP\Utils\Query;
1616

17-
use function chillerlan\HTTP\Utils\get_json;
18-
1917
use function explode, parse_url, sleep, time;
20-
2118
use const PHP_URL_QUERY;
2219

2320
/**
@@ -131,7 +128,7 @@ public function testRequest():void{
131128
$token = new AccessToken(['accessToken' => 'test_access_token_secret', 'expires' => 1]);
132129
$this->storage->storeAccessToken($this->provider->serviceName, $token);
133130

134-
$this::assertSame('such data! much wow!', get_json($this->provider->request('/request'))->data);
131+
$this::assertSame('such data! much wow!', $this->responseJson($this->provider->request('/request'))->data);
135132
}
136133

137134
public function testRequestInvalidAuthTypeException():void{
@@ -229,7 +226,7 @@ public function testRequestWithTokenRefresh():void{
229226

230227
sleep(2);
231228

232-
$this::assertSame('such data! much wow!', get_json($this->provider->request('/request'))->data);
229+
$this::assertSame('such data! much wow!', $this->responseJson($this->provider->request('/request'))->data);
233230
}
234231

235232
public function testGetClientCredentials():void{

tests/Providers/RequestTest/OAuthProviderRequestTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testCallMagicEndpoints():void{
6969
// get with path segment and query
7070
$r = $this->provider->test('withpath', 'andquery', ['foo' => 'bar', 'this-param' => 'does not exist']);
7171
$this::assertSame(
72-
'https://localhost/api/test/withpath/andquery/__echo__?foo=bar',
72+
'https://localhost/api/test/withpath/andquery'.$this::ECHO_REQUEST.'?foo=bar',
7373
$r->getHeaderLine('x-request-uri')
7474
);
7575

@@ -81,31 +81,31 @@ public function testCallMagicEndpoints():void{
8181
$r = $this->provider->postNoPathNoQuery($body);
8282
$this::assertSame($expectedBody, (string)$r->getBody());
8383
$this::assertSame(
84-
'https://localhost/api/post/nopathnoquery/__echo__',
84+
'https://localhost/api/post/nopathnoquery'.$this::ECHO_REQUEST,
8585
$r->getHeaderLine('x-request-uri')
8686
);
8787

8888
// path segment and body
8989
$r = $this->provider->postWithPathNoQuery('withpathnoquery', $body);
9090
$this::assertSame($expectedBody, (string)$r->getBody());
9191
$this::assertSame(
92-
'https://localhost/api/post/withpathnoquery/__echo__',
92+
'https://localhost/api/post/withpathnoquery'.$this::ECHO_REQUEST,
9393
$r->getHeaderLine('x-request-uri')
9494
);
9595

9696
// query parameters and body
9797
$r = $this->provider->postNoPathWithQuery($params, $body);
9898
$this::assertSame($expectedBody, (string)$r->getBody());
9999
$this::assertSame(
100-
'https://localhost/api/post/nopathwithquery/__echo__?query=whatever',
100+
'https://localhost/api/post/nopathwithquery'.$this::ECHO_REQUEST.'?query=whatever',
101101
$r->getHeaderLine('x-request-uri')
102102
);
103103

104104
// path segment, query params and body
105105
$r = $this->provider->postWithPathAndQuery('withpathandquery', $params, $body);
106106
$this::assertSame($expectedBody, (string)$r->getBody());
107107
$this::assertSame(
108-
'https://localhost/api/post/withpathandquery/__echo__?query=whatever',
108+
'https://localhost/api/post/withpathandquery'.$this::ECHO_REQUEST.'?query=whatever',
109109
$r->getHeaderLine('x-request-uri')
110110
);
111111

tests/Providers/TestEndpoints.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TestEndpoints extends EndpointMap{
1717
protected string $API_BASE = '/api';
1818

1919
protected array $test = [
20-
'path' => '/test/%1$s/%2$s/__echo__',
20+
'path' => '/test/%1$s/%2$s'.OAuthProviderTestAbstract::ECHO_REQUEST,
2121
'method' => 'GET',
2222
'query' => ['foo'],
2323
'path_elements' => ['a', 'b'],
@@ -26,7 +26,7 @@ class TestEndpoints extends EndpointMap{
2626
];
2727

2828
protected array $postNoPathNoQuery = [
29-
'path' => '/post/nopathnoquery/__echo__',
29+
'path' => '/post/nopathnoquery'.OAuthProviderTestAbstract::ECHO_REQUEST,
3030
'method' => 'POST',
3131
'query' => null,
3232
'path_elements' => null,
@@ -35,7 +35,7 @@ class TestEndpoints extends EndpointMap{
3535
];
3636

3737
protected array $postWithPathNoQuery = [
38-
'path' => '/post/%1$s/__echo__',
38+
'path' => '/post/%1$s'.OAuthProviderTestAbstract::ECHO_REQUEST,
3939
'method' => 'POST',
4040
'query' => null,
4141
'path_elements' => ['path'],
@@ -44,7 +44,7 @@ class TestEndpoints extends EndpointMap{
4444
];
4545

4646
protected array $postNoPathWithQuery = [
47-
'path' => '/post/nopathwithquery/__echo__',
47+
'path' => '/post/nopathwithquery'.OAuthProviderTestAbstract::ECHO_REQUEST,
4848
'method' => 'POST',
4949
'query' => ['query'],
5050
'path_elements' => null,
@@ -53,7 +53,7 @@ class TestEndpoints extends EndpointMap{
5353
];
5454

5555
protected array $postWithPathAndQuery = [
56-
'path' => '/post/%1$s/__echo__',
56+
'path' => '/post/%1$s'.OAuthProviderTestAbstract::ECHO_REQUEST,
5757
'method' => 'POST',
5858
'query' => ['query'],
5959
'path_elements' => ['pathandquery'],

0 commit comments

Comments
 (0)