Skip to content

Commit 87e646a

Browse files
committed
update testcase.
1 parent 106f3b9 commit 87e646a

File tree

1 file changed

+50
-49
lines changed

1 file changed

+50
-49
lines changed

tests/OSS/Tests/ListBucketsResultTest.php

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,53 @@ class ListBucketsResultTest extends \PHPUnit\Framework\TestCase
4242
</ListAllMyBucketsResult>
4343
BBBB;
4444

45+
46+
private $errorBody = <<< BBBB
47+
<?xml version="1.0" encoding="UTF-8"?>
48+
<Error>
49+
<Code>NoSuchBucket</Code>
50+
<Message>The specified bucket does not exist.</Message>
51+
<RequestId>566B870D207FB3044302EB0A</RequestId>
52+
<HostId>hello.oss-test.aliyun-inc.com</HostId>
53+
<BucketName>hello</BucketName>
54+
</Error>
55+
BBBB;
56+
57+
private $xml = <<<BBBB
58+
<?xml version="1.0" encoding="UTF-8"?>
59+
<ListAllMyBucketsResult>
60+
<Owner>
61+
<ID>ut_test_put_bucket</ID>
62+
<DisplayName>ut_test_put_bucket</DisplayName>
63+
</Owner>
64+
<Buckets>
65+
<Bucket>
66+
<CreationDate>2015-12-17T18:12:43.000Z</CreationDate>
67+
<ExtranetEndpoint>oss-cn-shanghai.aliyuncs.com</ExtranetEndpoint>
68+
<IntranetEndpoint>oss-cn-shanghai-internal.aliyuncs.com</IntranetEndpoint>
69+
<Location>oss-cn-shanghai</Location>
70+
<Name>app-base-oss</Name>
71+
<Region>cn-shanghai</Region>
72+
<StorageClass>Standard</StorageClass>
73+
</Bucket>
74+
<Bucket>
75+
<CreationDate>2014-12-25T11:21:04.000Z</CreationDate>
76+
<ExtranetEndpoint>oss-cn-hangzhou.aliyuncs.com</ExtranetEndpoint>
77+
<IntranetEndpoint>oss-cn-hangzhou-internal.aliyuncs.com</IntranetEndpoint>
78+
<Location>oss-cn-hangzhou</Location>
79+
<Name>atestleo23</Name>
80+
<Region>cn-hangzhou</Region>
81+
<StorageClass>IA</StorageClass>
82+
</Bucket>
83+
<Bucket>
84+
<CreationDate>2014-12-25T11:21:04.000Z</CreationDate>
85+
<Location>oss-cn-hangzhou</Location>
86+
<Name>atestleo23</Name>
87+
</Bucket>
88+
</Buckets>
89+
</ListAllMyBucketsResult>
90+
BBBB;
91+
4592
public function testParseValidXml()
4693
{
4794
$response = new ResponseCore(array(), $this->validXml, 200);
@@ -69,18 +116,7 @@ public function test403()
69116
$errorHeader = array(
70117
'x-oss-request-id' => '1a2b-3c4d'
71118
);
72-
73-
$errorBody = <<< BBBB
74-
<?xml version="1.0" encoding="UTF-8"?>
75-
<Error>
76-
<Code>NoSuchBucket</Code>
77-
<Message>The specified bucket does not exist.</Message>
78-
<RequestId>566B870D207FB3044302EB0A</RequestId>
79-
<HostId>hello.oss-test.aliyun-inc.com</HostId>
80-
<BucketName>hello</BucketName>
81-
</Error>
82-
BBBB;
83-
$response = new ResponseCore($errorHeader, $errorBody, 403);
119+
$response = new ResponseCore($errorHeader, $this->errorBody, 403);
84120
try {
85121
new ListBucketsResult($response);
86122
} catch (OssException $e) {
@@ -91,48 +127,13 @@ public function test403()
91127
$this->assertEquals($e->getRequestId(), '1a2b-3c4d');
92128
$this->assertEquals($e->getErrorCode(), 'NoSuchBucket');
93129
$this->assertEquals($e->getErrorMessage(), 'The specified bucket does not exist.');
94-
$this->assertEquals($e->getDetails(), $errorBody);
130+
$this->assertEquals($e->getDetails(), $this->errorBody);
95131
}
96132
}
97133

98134
public function testParseXml2()
99135
{
100-
$xml = <<<BBBB
101-
<?xml version="1.0" encoding="UTF-8"?>
102-
<ListAllMyBucketsResult>
103-
<Owner>
104-
<ID>ut_test_put_bucket</ID>
105-
<DisplayName>ut_test_put_bucket</DisplayName>
106-
</Owner>
107-
<Buckets>
108-
<Bucket>
109-
<CreationDate>2015-12-17T18:12:43.000Z</CreationDate>
110-
<ExtranetEndpoint>oss-cn-shanghai.aliyuncs.com</ExtranetEndpoint>
111-
<IntranetEndpoint>oss-cn-shanghai-internal.aliyuncs.com</IntranetEndpoint>
112-
<Location>oss-cn-shanghai</Location>
113-
<Name>app-base-oss</Name>
114-
<Region>cn-shanghai</Region>
115-
<StorageClass>Standard</StorageClass>
116-
</Bucket>
117-
<Bucket>
118-
<CreationDate>2014-12-25T11:21:04.000Z</CreationDate>
119-
<ExtranetEndpoint>oss-cn-hangzhou.aliyuncs.com</ExtranetEndpoint>
120-
<IntranetEndpoint>oss-cn-hangzhou-internal.aliyuncs.com</IntranetEndpoint>
121-
<Location>oss-cn-hangzhou</Location>
122-
<Name>atestleo23</Name>
123-
<Region>cn-hangzhou</Region>
124-
<StorageClass>IA</StorageClass>
125-
</Bucket>
126-
<Bucket>
127-
<CreationDate>2014-12-25T11:21:04.000Z</CreationDate>
128-
<Location>oss-cn-hangzhou</Location>
129-
<Name>atestleo23</Name>
130-
</Bucket>
131-
</Buckets>
132-
</ListAllMyBucketsResult>
133-
BBBB;
134-
135-
$response = new ResponseCore(array(), $xml, 200);
136+
$response = new ResponseCore(array(), $this->xml, 200);
136137
$result = new ListBucketsResult($response);
137138
$this->assertTrue($result->isOK());
138139
$this->assertNotNull($result->getData());

0 commit comments

Comments
 (0)