-
Notifications
You must be signed in to change notification settings - Fork 41
/
TestCase.php
47 lines (41 loc) · 1.71 KB
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace KuCoin\SDK\Tests;
use KuCoin\SDK\Auth;
use KuCoin\SDK\Http\GuzzleHttp;
use KuCoin\SDK\KuCoinApi;
class TestCase extends \PHPUnit\Framework\TestCase
{
protected $apiClass = 'Must be declared in the subclass';
protected $apiWithAuth = false;
public function apiProvider()
{
$apiKey = getenv('API_KEY');
$apiSecret = getenv('API_SECRET');
$apiPassPhrase = getenv('API_PASSPHRASE');
$apiBaseUri = getenv('API_BASE_URI');
$apiSkipVerifyTls = (bool)getenv('API_SKIP_VERIFY_TLS');
$apiDebugMode = (bool)getenv('API_DEBUG_MODE');
$apiKeyVersion = getenv('API_KEY_VERSION') ?: Auth::API_KEY_VERSION_V2;
KuCoinApi::setSkipVerifyTls($apiSkipVerifyTls);
KuCoinApi::setDebugMode($apiDebugMode);
if ($apiBaseUri) {
KuCoinApi::setBaseUri($apiBaseUri);
}
$auth = new Auth($apiKey, $apiSecret, $apiPassPhrase, $apiKeyVersion);
return [
[new $this->apiClass($this->apiWithAuth ? $auth : null)],
[new $this->apiClass($this->apiWithAuth ? $auth : null, new GuzzleHttp(['skipVerifyTls' => $apiSkipVerifyTls]))],
//[new $this->apiClass($this->apiWithAuth ? $auth : null, new SwooleHttp(['skipVerifyTls' => $apiSkipVerifyTls]))],
];
}
protected function assertPagination($data)
{
$this->assertInternalType('array', $data);
$this->assertArrayHasKey('totalNum', $data);
$this->assertArrayHasKey('totalPage', $data);
$this->assertArrayHasKey('pageSize', $data);
$this->assertArrayHasKey('currentPage', $data);
$this->assertArrayHasKey('items', $data);
$this->assertInternalType('array', $data['items']);
}
}