Skip to content

Commit 11db11a

Browse files
committed
clean test cases
1 parent 8e6d69f commit 11db11a

File tree

168 files changed

+1069
-11780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+1069
-11780
lines changed

.github/workflows/ci_higher_than_or_equal_to_7.2.yml .github/workflows/ci.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
15+
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
16+
fail-fast: false
1617

1718
steps:
1819
- name: Checkout
19-
uses: actions/checkout@v2
20+
uses: actions/checkout@v3
2021

21-
- uses: actions/setup-node@v1
22+
- uses: actions/setup-node@v4
2223
with:
2324
node-version: 10.x
2425

2526
- name: Install Proxy
26-
run: npm install o_o -g --registry=https://registry.npm.taobao.org
27+
run: npm install o_o -g --registry=https://registry.npmmirror.com
2728

2829
- name: Start Proxy
2930
run: o_o &
@@ -44,7 +45,7 @@ jobs:
4445
run: composer install --prefer-dist --no-progress --no-suggest
4546

4647
- name: Run test case
47-
run: composer test4HighVersion
48+
run: composer test
4849
env:
4950
REGION_ID: ${{ secrets.REGION_ID }}
5051
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}

.github/workflows/ci_lower_than_php7.2.yml

-59
This file was deleted.

composer.json

+4-20
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,13 @@
9797
"test": [
9898
"phpunit --colors=always"
9999
],
100-
"test4HighVersion": [
100+
"unit": [
101101
"@clearCache",
102-
"phpunit --testsuite=Test4HighVersion --colors=always"
102+
"phpunit --testsuite=Unit --colors=always"
103103
],
104-
"test4LowVersion": [
104+
"feature": [
105105
"@clearCache",
106-
"phpunit --testsuite=Test4LowVersion --colors=always"
107-
],
108-
"unit4HighVersion": [
109-
"@clearCache",
110-
"phpunit --testsuite=Unit4HighVersion --colors=always"
111-
],
112-
"unit4LowVersion": [
113-
"@clearCache",
114-
"phpunit --testsuite=Unit4LowVersion --colors=always"
115-
],
116-
"feature4HighVersion": [
117-
"@clearCache",
118-
"phpunit --testsuite=Feature4HighVersion --colors=always"
119-
],
120-
"feature4LowVersion": [
121-
"@clearCache",
122-
"phpunit --testsuite=Feature4LowVersion --colors=always"
106+
"phpunit --testsuite=Feature --colors=always"
123107
],
124108
"coverage": "open cache/coverage/index.html",
125109
"clearCache": "rm -rf cache/*",

phpunit.xml

+4-18
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,12 @@
1414
<testsuite name="All">
1515
<directory>tests</directory>
1616
</testsuite>
17-
<testsuite name="Test4HighVersion">
18-
<directory>./tests/HigherthanorEqualtoVersion7_2</directory>
19-
</testsuite>
20-
<testsuite name="Test4LowVersion">
21-
<directory>./tests/LowerthanVersion7_2</directory>
22-
</testsuite>
23-
<testsuite name="Unit4HighVersion">
24-
<directory suffix="Test.php">./tests/HigherthanorEqualtoVersion7_2/Unit</directory>
25-
</testsuite>
26-
27-
<testsuite name="Feature4HighVersion">
28-
<directory suffix="Test.php">./tests/HigherthanorEqualtoVersion7_2/Feature</directory>
29-
</testsuite>
30-
31-
<testsuite name="Unit4LowVersion">
32-
<directory suffix="Test.php">./tests/LowerthanVersion7_2/Unit</directory>
17+
<testsuite name="Unit">
18+
<directory suffix="Test.php">./tests/Unit</directory>
3319
</testsuite>
3420

35-
<testsuite name="Feature4LowVersion">
36-
<directory suffix="Test.php">./tests/LowerthanVersion7_2/Feature</directory>
21+
<testsuite name="Feature">
22+
<directory suffix="Test.php">./tests/Feature</directory>
3723
</testsuite>
3824
</testsuites>
3925

tests/LowerthanVersion7_2/Feature/Credentials/AccessKeyCredentialTest.php tests/Feature/Credentials/AccessKeyCredentialTest.php

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace AlibabaCloud\Client\Tests\LowerthanVersion7_2\Feature\Credentials;
3+
namespace AlibabaCloud\Client\Tests\Feature\Credentials;
44

55
use PHPUnit\Framework\TestCase;
66
use AlibabaCloud\Client\AlibabaCloud;
@@ -14,7 +14,7 @@
1414
/**
1515
* Class AccessKeyCredentialTest
1616
*
17-
* @package AlibabaCloud\Client\Tests\LowerthanVersion7_2\Feature\Credentials
17+
* @package AlibabaCloud\Client\Tests\Feature\Credentials
1818
*/
1919
class AccessKeyCredentialTest extends TestCase
2020
{
@@ -25,23 +25,27 @@ class AccessKeyCredentialTest extends TestCase
2525
private $clientName = 'AccessKeyCredentialTest';
2626

2727
/**
28+
* @before
2829
* @throws ClientException
2930
*/
30-
public function setUp()
31+
protected function initialize()
3132
{
32-
$regionId = 'cn-hangzhou';
33-
$accessKeyId = \getenv('ACCESS_KEY_ID');
33+
parent::setUp();
34+
$regionId = 'cn-hangzhou';
35+
$accessKeyId = \getenv('ACCESS_KEY_ID');
3436
$accessKeySecret = \getenv('ACCESS_KEY_SECRET');
3537
AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)
36-
->regionId($regionId)
37-
->name($this->clientName);
38+
->regionId($regionId)
39+
->name($this->clientName);
3840
}
3941

4042
/**
43+
* @after
4144
* @throws ClientException
4245
*/
43-
public function tearDown()
46+
protected function finalize()
4447
{
48+
parent::tearDown();
4549
AlibabaCloud::del($this->clientName);
4650
}
4751

@@ -51,13 +55,15 @@ public function tearDown()
5155
*/
5256
public function testEcs()
5357
{
58+
5459
$result = (new DescribeAccessPointsRequest())
5560
->client($this->clientName)
5661
->connectTimeout(25)
5762
->timeout(30)
5863
->request();
5964

6065
static::assertArrayHasKey('AccessPointSet', $result);
66+
6167
}
6268

6369
/**
@@ -66,30 +72,32 @@ public function testEcs()
6672
*/
6773
public function testDds()
6874
{
75+
6976
$result = (new DescribeRegionsRequest())
7077
->client($this->clientName)
7178
->connectTimeout(25)
7279
->timeout(30)
7380
->request();
7481

7582
static::assertArrayHasKey('Regions', $result);
83+
7684
}
7785

7886
/**
79-
* @expectedException \AlibabaCloud\Client\Exception\ServerException
80-
* @expectedExceptionMessageRegExp /Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/
8187
* @throws ClientException
8288
* @throws ServerException
8389
*/
8490
public function testCdn()
8591
{
92+
8693
$result = (new DescribeCdnServiceRequest())
8794
->client($this->clientName)
8895
->connectTimeout(25)
8996
->timeout(30)
9097
->request();
9198

92-
// static::assertArrayHasKey('ChangingChargeType', $result);
99+
static::assertArrayHasKey('ChangingChargeType', $result);
100+
93101
}
94102

95103
/**
@@ -98,12 +106,14 @@ public function testCdn()
98106
*/
99107
public function testVpc()
100108
{
109+
101110
$result = (new DescribeVpcsRequest())
102111
->client($this->clientName)
103112
->connectTimeout(25)
104113
->timeout(30)
105114
->request();
106115

107116
static::assertArrayHasKey('Vpcs', $result);
117+
108118
}
109119
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Feature\Credentials;
3+
namespace AlibabaCloud\Client\Tests\Feature\Credentials;
44

55
use PHPUnit\Framework\TestCase;
66
use AlibabaCloud\Client\AlibabaCloud;
@@ -13,7 +13,7 @@
1313
/**
1414
* Class BearerTokenCredentialTest
1515
*
16-
* @package AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Feature\Credentials
16+
* @package AlibabaCloud\Client\Tests\Feature\Credentials
1717
*/
1818
class BearerTokenCredentialTest extends TestCase
1919
{
@@ -24,23 +24,27 @@ class BearerTokenCredentialTest extends TestCase
2424
protected $clientName = 'BearerTokenCredentialTest';
2525

2626
/**
27+
* @before
2728
* @throws ClientException
2829
*/
29-
public function setUp(): void
30+
protected function initialize()
3031
{
31-
$regionId = 'cn-hangzhou';
32+
parent::setUp();
33+
$regionId = 'cn-hangzhou';
3234
$bearerToken =
3335
'eyJhbGciOiJSUzI1NiIsImsyaWQiOiJlNE92NnVOUDhsMEY2RmVUMVhvek5wb1NBcVZLblNGRyIsImtpZCI6IkpDOXd4enJocUowZ3RhQ0V0MlFMVWZldkVVSXdsdEZodWk0TzFiaDY3dFUifQ.N3plS0w2cm83YzhtVzJqSkI0U0JIMldzNW45cFBOSWdNellvQ3VpZGV5NzRVOHNsMkJUWTVULzl3RDdkbzhHQkorM3dvclg1SGY1STZXL1FjaVhLVnc5ck5YeVNYanBuK2N6UkN1SnRRc3FRMGJIVTF4cVVjUDVRNUJpK2JsSWxZdlowZ2VWSzYvS2pzcVNjWHJLSlVvWkNnWE0wWGJZZ0NCVm1BUlNXS1plUnNzdnAvUmwwV01tSFFkWmlOMGtKV0o5TllQU3M0QU1aenpHVTdUY1BnYlhIVy9uTmdMY1JVSytROXlrPQ.kvZes7-6IU-xjOzK1goPPjODz1XLt73yCmDLSpRwzlz3d9A_uYvbQK0HHltVKo0K0dI0wJOfpCeOHJlrV0m4RI4bynL9ltl31rscPhQ-G4Ybqw4KXVBZCIzjSqzWcniIWnGWl-TpOy0Y7sAcJmp0Lg2ndu_shGqiTP6DTVBNV8f94mveHmRqouLxr2OKMvCyxTV1zUEJmC-JnZaljfNG-i483qG8Hm60CwAjM91FTGib3eXGzjJa3XOOY7zpZTrvahBYFpyrVhRuvDvRs6tLKVAL_7bYwCIo_tdh9rhRmFtyq0k2iykZQJmAIlDMt-VENP7hJTH62uUQzNLQ28ISTQ';
3436
AlibabaCloud::bearerTokenClient($bearerToken)
35-
->regionId($regionId)
36-
->name($this->clientName);
37+
->regionId($regionId)
38+
->name($this->clientName);
3739
}
3840

3941
/**
42+
* @after
4043
* @throws ClientException
4144
*/
42-
public function tearDown(): void
45+
protected function finalize()
4346
{
47+
parent::tearDown();
4448
AlibabaCloud::del($this->clientName);
4549
}
4650

@@ -49,6 +53,7 @@ public function tearDown(): void
4953
*/
5054
public function testCCC()
5155
{
56+
5257
try {
5358
(new ListPhoneNumbersRequest())
5459
->client($this->clientName)
@@ -57,8 +62,8 @@ public function testCCC()
5762
->scheme('https')
5863
->host('ccc.cn-shanghai.aliyuncs.com')
5964
->options([
60-
'verify' => false,
61-
])
65+
'verify' => false,
66+
])
6267
->connectTimeout(25)
6368
->timeout(30)
6469
->request();
@@ -69,32 +74,47 @@ public function testCCC()
6974
$result['Message']
7075
);
7176
}
77+
7278
}
7379

7480
/**
7581
* @throws ClientException
7682
*/
7783
public function testEcs()
7884
{
85+
7986
$this->expectException(ServerException::class);
80-
$this->expectExceptionMessageMatches('/UnsupportedSignatureType: This signature type is not supported./');
87+
$reg = '/UnsupportedSignatureType: This signature type is not supported./';
88+
if (method_exists($this, 'expectExceptionMessageMatches')) {
89+
$this->expectExceptionMessageMatches($reg);
90+
} elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
91+
$this->expectExceptionMessageRegExp($reg);
92+
}
8193
(new DescribeAccessPointsRequest())
8294
->client($this->clientName)
8395
->connectTimeout(25)
8496
->timeout(30)
8597
->request();
98+
8699
}
87100

88101
/**
89102
* @throws ClientException
90103
*/
91104
public function testCdn()
92105
{
106+
93107
$this->expectException(ServerException::class);
94-
$this->expectExceptionMessageMatches('/UnsupportedSignatureType: This signature type is not supported./');
108+
$reg = '/UnsupportedSignatureType: This signature type is not supported./';
109+
if (method_exists($this, 'expectExceptionMessageMatches')) {
110+
$this->expectExceptionMessageMatches($reg);
111+
} elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
112+
$this->expectExceptionMessageRegExp($reg);
113+
}
95114
(new DescribeCdnServiceRequest())->client($this->clientName)
96-
->connectTimeout(25)
97-
->timeout(30)
98-
->request();
115+
->connectTimeout(25)
116+
->timeout(30)
117+
->request();
118+
99119
}
100120
}

0 commit comments

Comments
 (0)