Skip to content

Commit de318fb

Browse files
committed
clean test cases
1 parent 8e6d69f commit de318fb

File tree

166 files changed

+306
-11344
lines changed

Some content is hidden

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

166 files changed

+306
-11344
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ 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']
1616

1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v3
2020

21-
- uses: actions/setup-node@v1
21+
- uses: actions/setup-node@v4
2222
with:
2323
node-version: 10.x
2424

@@ -44,7 +44,7 @@ jobs:
4444
run: composer install --prefer-dist --no-progress --no-suggest
4545

4646
- name: Run test case
47-
run: composer test4HighVersion
47+
run: composer test
4848
env:
4949
REGION_ID: ${{ secrets.REGION_ID }}
5050
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

+6-17
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,15 @@
1414
<testsuite name="All">
1515
<directory>tests</directory>
1616
</testsuite>
17-
<testsuite name="Test4HighVersion">
18-
<directory>./tests/HigherthanorEqualtoVersion7_2</directory>
17+
<testsuite name="Test">
18+
<directory>./tests</directory>
1919
</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>
20+
<testsuite name="Unit">
21+
<directory suffix="Test.php">./tests/Unit</directory>
3322
</testsuite>
3423

35-
<testsuite name="Feature4LowVersion">
36-
<directory suffix="Test.php">./tests/LowerthanVersion7_2/Feature</directory>
24+
<testsuite name="Feature">
25+
<directory suffix="Test.php">./tests/Feature</directory>
3726
</testsuite>
3827
</testsuites>
3928

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;
@@ -14,7 +14,7 @@
1414
/**
1515
* Class AccessKeyCredentialTest
1616
*
17-
* @package AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Feature\Credentials
17+
* @package AlibabaCloud\Client\Tests\Feature\Credentials
1818
*/
1919
class AccessKeyCredentialTest extends TestCase
2020
{
@@ -25,10 +25,12 @@ class AccessKeyCredentialTest extends TestCase
2525
private $clientName = 'AccessKeyCredentialTest';
2626

2727
/**
28+
* @before
2829
* @throws ClientException
2930
*/
30-
public function setUp(): void
31+
public function initialize()
3132
{
33+
parent::setUp();
3234
$regionId = 'cn-hangzhou';
3335
$accessKeyId = \getenv('ACCESS_KEY_ID');
3436
$accessKeySecret = \getenv('ACCESS_KEY_SECRET');
@@ -38,10 +40,12 @@ public function setUp(): void
3840
}
3941

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

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,10 +24,12 @@ class BearerTokenCredentialTest extends TestCase
2424
protected $clientName = 'BearerTokenCredentialTest';
2525

2626
/**
27+
* @before
2728
* @throws ClientException
2829
*/
29-
public function setUp(): void
30+
public function initialize()
3031
{
32+
parent::setUp();
3133
$regionId = 'cn-hangzhou';
3234
$bearerToken =
3335
'eyJhbGciOiJSUzI1NiIsImsyaWQiOiJlNE92NnVOUDhsMEY2RmVUMVhvek5wb1NBcVZLblNGRyIsImtpZCI6IkpDOXd4enJocUowZ3RhQ0V0MlFMVWZldkVVSXdsdEZodWk0TzFiaDY3dFUifQ.N3plS0w2cm83YzhtVzJqSkI0U0JIMldzNW45cFBOSWdNellvQ3VpZGV5NzRVOHNsMkJUWTVULzl3RDdkbzhHQkorM3dvclg1SGY1STZXL1FjaVhLVnc5ck5YeVNYanBuK2N6UkN1SnRRc3FRMGJIVTF4cVVjUDVRNUJpK2JsSWxZdlowZ2VWSzYvS2pzcVNjWHJLSlVvWkNnWE0wWGJZZ0NCVm1BUlNXS1plUnNzdnAvUmwwV01tSFFkWmlOMGtKV0o5TllQU3M0QU1aenpHVTdUY1BnYlhIVy9uTmdMY1JVSytROXlrPQ.kvZes7-6IU-xjOzK1goPPjODz1XLt73yCmDLSpRwzlz3d9A_uYvbQK0HHltVKo0K0dI0wJOfpCeOHJlrV0m4RI4bynL9ltl31rscPhQ-G4Ybqw4KXVBZCIzjSqzWcniIWnGWl-TpOy0Y7sAcJmp0Lg2ndu_shGqiTP6DTVBNV8f94mveHmRqouLxr2OKMvCyxTV1zUEJmC-JnZaljfNG-i483qG8Hm60CwAjM91FTGib3eXGzjJa3XOOY7zpZTrvahBYFpyrVhRuvDvRs6tLKVAL_7bYwCIo_tdh9rhRmFtyq0k2iykZQJmAIlDMt-VENP7hJTH62uUQzNLQ28ISTQ';
@@ -37,10 +39,12 @@ public function setUp(): void
3739
}
3840

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

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;
@@ -11,7 +11,7 @@
1111
/**
1212
* Class EcsRamRoleCredentialTest
1313
*
14-
* @package AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Feature\Credentials
14+
* @package AlibabaCloud\Client\Tests\Feature\Credentials
1515
*/
1616
class EcsRamRoleCredentialTest extends TestCase
1717
{
@@ -25,10 +25,12 @@ class EcsRamRoleCredentialTest extends TestCase
2525
* Sets up the fixture, for example, open a network connection.
2626
* This method is called before a test is executed.
2727
*
28+
* @before
2829
* @throws ClientException
2930
*/
30-
public function setUp(): void
31+
public function initialize()
3132
{
33+
parent::setUp();
3234
$regionId = 'cn-hangzhou';
3335
$roleName = 'EcsRamRoleTest';
3436
AlibabaCloud::ecsRamRoleClient($roleName)
@@ -40,10 +42,12 @@ public function setUp(): void
4042
* Tears down the fixture, for example, close a network connection.
4143
* This method is called after a test is executed.
4244
*
45+
* @after
4346
* @throws ClientException
4447
*/
45-
public function tearDown(): void
48+
public function finalize()
4649
{
50+
parent::tearDown();
4751
AlibabaCloud::del($this->clientName);
4852
}
4953

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
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;
77
use AlibabaCloud\Client\Exception\ClientException;
88
use AlibabaCloud\Client\Credentials\Ini\IniCredential;
9-
use AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Unit\Credentials\Ini\VirtualAccessKeyCredential;
10-
use AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Unit\Credentials\Ini\VirtualRamRoleArnCredential;
11-
use AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Unit\Credentials\Ini\VirtualRsaKeyPairCredential;
12-
use AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Unit\Credentials\Ini\VirtualEcsRamRoleCredential;
13-
use AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Unit\Credentials\Ini\VirtualBearerTokenCredential;
9+
use AlibabaCloud\Client\Tests\Unit\Credentials\Ini\VirtualAccessKeyCredential;
10+
use AlibabaCloud\Client\Tests\Unit\Credentials\Ini\VirtualRamRoleArnCredential;
11+
use AlibabaCloud\Client\Tests\Unit\Credentials\Ini\VirtualRsaKeyPairCredential;
12+
use AlibabaCloud\Client\Tests\Unit\Credentials\Ini\VirtualEcsRamRoleCredential;
13+
use AlibabaCloud\Client\Tests\Unit\Credentials\Ini\VirtualBearerTokenCredential;
1414

1515
/**
1616
* Class IniCredentialFeatureTest
1717
*
18-
* @package AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Feature\Credentials
18+
* @package AlibabaCloud\Client\Tests\Feature\Credentials
1919
*
2020
* @coversDefaultClass \AlibabaCloud\Client\Credentials\Ini\IniCredential
2121
*/
2222
class IniCredentialFeatureTest extends TestCase
2323
{
24+
/**
25+
* @after
26+
* @throws ClientException
27+
*/
28+
public function finalize()
29+
{
30+
parent::tearDown();
31+
AlibabaCloud::del('phpunit');
32+
IniCredential::forgetLoadedCredentialsFile();
33+
}
34+
2435

2536
public function testBadFormat()
2637
{
@@ -85,15 +96,6 @@ public function testNoSecret()
8596
AlibabaCloud::load(VirtualAccessKeyCredential::noSecret());
8697
}
8798

88-
/**
89-
* @throws ClientException
90-
*/
91-
public function tearDown(): void
92-
{
93-
AlibabaCloud::del('phpunit');
94-
IniCredential::forgetLoadedCredentialsFile();
95-
}
96-
9799
/**
98100
* @throws ClientException
99101
*/
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;
@@ -11,7 +11,7 @@
1111
/**
1212
* Class RamRoleArnCredentialTest
1313
*
14-
* @package AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Feature\Credentials
14+
* @package AlibabaCloud\Client\Tests\Feature\Credentials
1515
*/
1616
class RamRoleArnCredentialTest extends TestCase
1717
{
@@ -22,10 +22,12 @@ class RamRoleArnCredentialTest extends TestCase
2222
private $clientName = 'RamRoleArnCredentialTest';
2323

2424
/**
25+
* @before
2526
* @throws ClientException
2627
*/
27-
public function setUp(): void
28+
protected function initialize()
2829
{
30+
parent::setUp();
2931
$regionId = 'cn-hangzhou';
3032
$accessKeyId = \getenv('ACCESS_KEY_ID');
3133
$accessKeySecret = \getenv('ACCESS_KEY_SECRET');
@@ -67,10 +69,12 @@ public function setUp(): void
6769
}
6870

6971
/**
72+
* @after
7073
* @throws ClientException
7174
*/
72-
public function tearDown(): void
75+
public function finalize()
7376
{
77+
parent::tearDown();
7478
AlibabaCloud::del($this->clientName);
7579
}
7680

0 commit comments

Comments
 (0)