This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathTestCase.php
51 lines (44 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
48
49
50
51
<?php
namespace KuMEX\SDK\Tests;
use KuMEX\SDK\Auth;
use KuMEX\SDK\Http\GuzzleHttp;
use KuMEX\SDK\KuMEXApi;
class TestCase extends \PHPUnit\Framework\TestCase
{
protected function setUp()
{
parent::setUp();
}
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');
KuMEXApi::setSkipVerifyTls($apiSkipVerifyTls);
KuMEXApi::setDebugMode($apiDebugMode);
if ($apiBaseUri) {
KuMEXApi::setBaseUri($apiBaseUri);
}
$auth = new Auth($apiKey, $apiSecret, $apiPassPhrase);
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']);
}
}