ut_test_put_bucket ut_test_put_bucket oss-cn-hangzhou-a xz02tphky6fjfiuc0 2014-05-15T11:18:32.000Z oss-cn-hangzhou-a xz02tphky6fjfiuc1 2014-05-15T11:18:32.000Z BBBB; private $nullXml = << ut_test_put_bucket ut_test_put_bucket BBBB; public function testParseValidXml() { $response = new ResponseCore(array(), $this->validXml, 200); $result = new ListBucketsResult($response); $this->assertTrue($result->isOK()); $this->assertNotNull($result->getData()); $this->assertNotNull($result->getRawResponse()); $bucketListInfo = $result->getData(); $this->assertEquals(2, count($bucketListInfo->getBucketList())); } public function testParseNullXml() { $response = new ResponseCore(array(), $this->nullXml, 200); $result = new ListBucketsResult($response); $this->assertTrue($result->isOK()); $this->assertNotNull($result->getData()); $this->assertNotNull($result->getRawResponse()); $bucketListInfo = $result->getData(); $this->assertEquals(0, count($bucketListInfo->getBucketList())); } public function test403() { $errorHeader = array( 'x-oss-request-id' => '1a2b-3c4d' ); $errorBody = <<< BBBB NoSuchBucket The specified bucket does not exist. 566B870D207FB3044302EB0A hello.oss-test.aliyun-inc.com hello BBBB; $response = new ResponseCore($errorHeader, $errorBody, 403); try { new ListBucketsResult($response); } catch (OssException $e) { $this->assertEquals( $e->getMessage(), 'NoSuchBucket: The specified bucket does not exist. RequestId: 1a2b-3c4d'); $this->assertEquals($e->getHTTPStatus(), '403'); $this->assertEquals($e->getRequestId(), '1a2b-3c4d'); $this->assertEquals($e->getErrorCode(), 'NoSuchBucket'); $this->assertEquals($e->getErrorMessage(), 'The specified bucket does not exist.'); $this->assertEquals($e->getDetails(), $errorBody); } } }