testbucket-hf 1000 / false oss-php-sdk-test/ test/ BBBB; private $validXml2 = << testbucket-hf oss-php-sdk-test/ xx 1000 / false oss-php-sdk-test/upload-test-object-name.txt 2015-11-18T03:36:00.000Z "89B9E567E7EB8815F2F7D41851F9A2CD" Normal 13115 Standard cname_user cname_user BBBB; private $validXmlWithEncodedKey = << testbucket-hf url php%2Fprefix php%2Fmarker php%2Fnext-marker 1000 %2F true php/a%2Bb 2015-11-18T03:36:00.000Z "89B9E567E7EB8815F2F7D41851F9A2CD" Normal 13115 Standard cname_user cname_user BBBB; public function testParseValidXml1() { $response = new ResponseCore(array(), $this->validXml1, 200); $result = new ListObjectsResult($response); $this->assertTrue($result->isOK()); $this->assertNotNull($result->getData()); $this->assertNotNull($result->getRawResponse()); $objectListInfo = $result->getData(); $this->assertEquals(2, count($objectListInfo->getPrefixList())); $this->assertEquals(0, count($objectListInfo->getObjectList())); $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); $this->assertEquals('', $objectListInfo->getPrefix()); $this->assertEquals('', $objectListInfo->getMarker()); $this->assertEquals(1000, $objectListInfo->getMaxKeys()); $this->assertEquals('/', $objectListInfo->getDelimiter()); $this->assertEquals('false', $objectListInfo->getIsTruncated()); $prefixes = $objectListInfo->getPrefixList(); $this->assertEquals('oss-php-sdk-test/', $prefixes[0]->getPrefix()); $this->assertEquals('test/', $prefixes[1]->getPrefix()); } public function testParseValidXml2() { $response = new ResponseCore(array(), $this->validXml2, 200); $result = new ListObjectsResult($response); $this->assertTrue($result->isOK()); $this->assertNotNull($result->getData()); $this->assertNotNull($result->getRawResponse()); $objectListInfo = $result->getData(); $this->assertEquals(0, count($objectListInfo->getPrefixList())); $this->assertEquals(1, count($objectListInfo->getObjectList())); $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); $this->assertEquals('oss-php-sdk-test/', $objectListInfo->getPrefix()); $this->assertEquals('xx', $objectListInfo->getMarker()); $this->assertEquals(1000, $objectListInfo->getMaxKeys()); $this->assertEquals('/', $objectListInfo->getDelimiter()); $this->assertEquals('false', $objectListInfo->getIsTruncated()); $objects = $objectListInfo->getObjectList(); $this->assertEquals('oss-php-sdk-test/upload-test-object-name.txt', $objects[0]->getKey()); $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); $this->assertEquals('Normal', $objects[0]->getType()); $this->assertEquals(13115, $objects[0]->getSize()); $this->assertEquals('Standard', $objects[0]->getStorageClass()); } public function testParseValidXmlWithEncodedKey() { $response = new ResponseCore(array(), $this->validXmlWithEncodedKey, 200); $result = new ListObjectsResult($response); $this->assertTrue($result->isOK()); $this->assertNotNull($result->getData()); $this->assertNotNull($result->getRawResponse()); $objectListInfo = $result->getData(); $this->assertEquals(0, count($objectListInfo->getPrefixList())); $this->assertEquals(1, count($objectListInfo->getObjectList())); $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); $this->assertEquals('php/prefix', $objectListInfo->getPrefix()); $this->assertEquals('php/marker', $objectListInfo->getMarker()); $this->assertEquals('php/next-marker', $objectListInfo->getNextMarker()); $this->assertEquals(1000, $objectListInfo->getMaxKeys()); $this->assertEquals('/', $objectListInfo->getDelimiter()); $this->assertEquals('true', $objectListInfo->getIsTruncated()); $objects = $objectListInfo->getObjectList(); $this->assertEquals('php/a+b', $objects[0]->getKey()); $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); $this->assertEquals('Normal', $objects[0]->getType()); $this->assertEquals(13115, $objects[0]->getSize()); $this->assertEquals('Standard', $objects[0]->getStorageClass()); } }