Skip to content

clean test cases #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 10.x

- name: Install Proxy
run: npm install o_o -g --registry=https://registry.npm.taobao.org
run: npm install o_o -g --registry=https://registry.npmmirror.com

- name: Start Proxy
run: o_o &
Expand All @@ -44,7 +45,7 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run test case
run: composer test4HighVersion
run: composer test
env:
REGION_ID: ${{ secrets.REGION_ID }}
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
Expand Down
59 changes: 0 additions & 59 deletions .github/workflows/ci_lower_than_php7.2.yml

This file was deleted.

24 changes: 4 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,29 +97,13 @@
"test": [
"phpunit --colors=always"
],
"test4HighVersion": [
"unit": [
"@clearCache",
"phpunit --testsuite=Test4HighVersion --colors=always"
"phpunit --testsuite=Unit --colors=always"
],
"test4LowVersion": [
"feature": [
"@clearCache",
"phpunit --testsuite=Test4LowVersion --colors=always"
],
"unit4HighVersion": [
"@clearCache",
"phpunit --testsuite=Unit4HighVersion --colors=always"
],
"unit4LowVersion": [
"@clearCache",
"phpunit --testsuite=Unit4LowVersion --colors=always"
],
"feature4HighVersion": [
"@clearCache",
"phpunit --testsuite=Feature4HighVersion --colors=always"
],
"feature4LowVersion": [
"@clearCache",
"phpunit --testsuite=Feature4LowVersion --colors=always"
"phpunit --testsuite=Feature --colors=always"
],
"coverage": "open cache/coverage/index.html",
"clearCache": "rm -rf cache/*",
Expand Down
22 changes: 4 additions & 18 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,12 @@
<testsuite name="All">
<directory>tests</directory>
</testsuite>
<testsuite name="Test4HighVersion">
<directory>./tests/HigherthanorEqualtoVersion7_2</directory>
</testsuite>
<testsuite name="Test4LowVersion">
<directory>./tests/LowerthanVersion7_2</directory>
</testsuite>
<testsuite name="Unit4HighVersion">
<directory suffix="Test.php">./tests/HigherthanorEqualtoVersion7_2/Unit</directory>
</testsuite>

<testsuite name="Feature4HighVersion">
<directory suffix="Test.php">./tests/HigherthanorEqualtoVersion7_2/Feature</directory>
</testsuite>

<testsuite name="Unit4LowVersion">
<directory suffix="Test.php">./tests/LowerthanVersion7_2/Unit</directory>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>

<testsuite name="Feature4LowVersion">
<directory suffix="Test.php">./tests/LowerthanVersion7_2/Feature</directory>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace AlibabaCloud\Client\Tests\LowerthanVersion7_2\Feature\Credentials;
namespace AlibabaCloud\Client\Tests\Feature\Credentials;

use PHPUnit\Framework\TestCase;
use AlibabaCloud\Client\AlibabaCloud;
Expand All @@ -14,7 +14,7 @@
/**
* Class AccessKeyCredentialTest
*
* @package AlibabaCloud\Client\Tests\LowerthanVersion7_2\Feature\Credentials
* @package AlibabaCloud\Client\Tests\Feature\Credentials
*/
class AccessKeyCredentialTest extends TestCase
{
Expand All @@ -25,23 +25,27 @@ class AccessKeyCredentialTest extends TestCase
private $clientName = 'AccessKeyCredentialTest';

/**
* @before
* @throws ClientException
*/
public function setUp()
protected function initialize()
{
$regionId = 'cn-hangzhou';
$accessKeyId = \getenv('ACCESS_KEY_ID');
parent::setUp();
$regionId = 'cn-hangzhou';
$accessKeyId = \getenv('ACCESS_KEY_ID');
$accessKeySecret = \getenv('ACCESS_KEY_SECRET');
AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)
->regionId($regionId)
->name($this->clientName);
->regionId($regionId)
->name($this->clientName);
}

/**
* @after
* @throws ClientException
*/
public function tearDown()
protected function finalize()
{
parent::tearDown();
AlibabaCloud::del($this->clientName);
}

Expand All @@ -51,13 +55,15 @@ public function tearDown()
*/
public function testEcs()
{

$result = (new DescribeAccessPointsRequest())
->client($this->clientName)
->connectTimeout(25)
->timeout(30)
->request();

static::assertArrayHasKey('AccessPointSet', $result);

}

/**
Expand All @@ -66,30 +72,32 @@ public function testEcs()
*/
public function testDds()
{

$result = (new DescribeRegionsRequest())
->client($this->clientName)
->connectTimeout(25)
->timeout(30)
->request();

static::assertArrayHasKey('Regions', $result);

}

/**
* @expectedException \AlibabaCloud\Client\Exception\ServerException
* @expectedExceptionMessageRegExp /Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/
* @throws ClientException
* @throws ServerException
*/
public function testCdn()
{

$result = (new DescribeCdnServiceRequest())
->client($this->clientName)
->connectTimeout(25)
->timeout(30)
->request();

// static::assertArrayHasKey('ChangingChargeType', $result);
static::assertArrayHasKey('ChangingChargeType', $result);

}

/**
Expand All @@ -98,12 +106,14 @@ public function testCdn()
*/
public function testVpc()
{

$result = (new DescribeVpcsRequest())
->client($this->clientName)
->connectTimeout(25)
->timeout(30)
->request();

static::assertArrayHasKey('Vpcs', $result);

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Feature\Credentials;
namespace AlibabaCloud\Client\Tests\Feature\Credentials;

use PHPUnit\Framework\TestCase;
use AlibabaCloud\Client\AlibabaCloud;
Expand All @@ -13,7 +13,7 @@
/**
* Class BearerTokenCredentialTest
*
* @package AlibabaCloud\Client\Tests\HigherthanorEqualtoVersion7_2\Feature\Credentials
* @package AlibabaCloud\Client\Tests\Feature\Credentials
*/
class BearerTokenCredentialTest extends TestCase
{
Expand All @@ -24,23 +24,27 @@ class BearerTokenCredentialTest extends TestCase
protected $clientName = 'BearerTokenCredentialTest';

/**
* @before
* @throws ClientException
*/
public function setUp(): void
protected function initialize()
{
$regionId = 'cn-hangzhou';
parent::setUp();
$regionId = 'cn-hangzhou';
$bearerToken =
'eyJhbGciOiJSUzI1NiIsImsyaWQiOiJlNE92NnVOUDhsMEY2RmVUMVhvek5wb1NBcVZLblNGRyIsImtpZCI6IkpDOXd4enJocUowZ3RhQ0V0MlFMVWZldkVVSXdsdEZodWk0TzFiaDY3dFUifQ.N3plS0w2cm83YzhtVzJqSkI0U0JIMldzNW45cFBOSWdNellvQ3VpZGV5NzRVOHNsMkJUWTVULzl3RDdkbzhHQkorM3dvclg1SGY1STZXL1FjaVhLVnc5ck5YeVNYanBuK2N6UkN1SnRRc3FRMGJIVTF4cVVjUDVRNUJpK2JsSWxZdlowZ2VWSzYvS2pzcVNjWHJLSlVvWkNnWE0wWGJZZ0NCVm1BUlNXS1plUnNzdnAvUmwwV01tSFFkWmlOMGtKV0o5TllQU3M0QU1aenpHVTdUY1BnYlhIVy9uTmdMY1JVSytROXlrPQ.kvZes7-6IU-xjOzK1goPPjODz1XLt73yCmDLSpRwzlz3d9A_uYvbQK0HHltVKo0K0dI0wJOfpCeOHJlrV0m4RI4bynL9ltl31rscPhQ-G4Ybqw4KXVBZCIzjSqzWcniIWnGWl-TpOy0Y7sAcJmp0Lg2ndu_shGqiTP6DTVBNV8f94mveHmRqouLxr2OKMvCyxTV1zUEJmC-JnZaljfNG-i483qG8Hm60CwAjM91FTGib3eXGzjJa3XOOY7zpZTrvahBYFpyrVhRuvDvRs6tLKVAL_7bYwCIo_tdh9rhRmFtyq0k2iykZQJmAIlDMt-VENP7hJTH62uUQzNLQ28ISTQ';
AlibabaCloud::bearerTokenClient($bearerToken)
->regionId($regionId)
->name($this->clientName);
->regionId($regionId)
->name($this->clientName);
}

/**
* @after
* @throws ClientException
*/
public function tearDown(): void
protected function finalize()
{
parent::tearDown();
AlibabaCloud::del($this->clientName);
}

Expand All @@ -49,6 +53,7 @@ public function tearDown(): void
*/
public function testCCC()
{

try {
(new ListPhoneNumbersRequest())
->client($this->clientName)
Expand All @@ -57,8 +62,8 @@ public function testCCC()
->scheme('https')
->host('ccc.cn-shanghai.aliyuncs.com')
->options([
'verify' => false,
])
'verify' => false,
])
->connectTimeout(25)
->timeout(30)
->request();
Expand All @@ -69,32 +74,47 @@ public function testCCC()
$result['Message']
);
}

}

/**
* @throws ClientException
*/
public function testEcs()
{

$this->expectException(ServerException::class);
$this->expectExceptionMessageMatches('/UnsupportedSignatureType: This signature type is not supported./');
$reg = '/UnsupportedSignatureType: This signature type is not supported./';
if (method_exists($this, 'expectExceptionMessageMatches')) {
$this->expectExceptionMessageMatches($reg);
} elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
$this->expectExceptionMessageRegExp($reg);
}
(new DescribeAccessPointsRequest())
->client($this->clientName)
->connectTimeout(25)
->timeout(30)
->request();

}

/**
* @throws ClientException
*/
public function testCdn()
{

$this->expectException(ServerException::class);
$this->expectExceptionMessageMatches('/UnsupportedSignatureType: This signature type is not supported./');
$reg = '/UnsupportedSignatureType: This signature type is not supported./';
if (method_exists($this, 'expectExceptionMessageMatches')) {
$this->expectExceptionMessageMatches($reg);
} elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
$this->expectExceptionMessageRegExp($reg);
}
(new DescribeCdnServiceRequest())->client($this->clientName)
->connectTimeout(25)
->timeout(30)
->request();
->connectTimeout(25)
->timeout(30)
->request();

}
}
Loading
Loading