ListPartsResultTest.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace OSS\Tests;
  3. use OSS\Result\ListPartsResult;
  4. use OSS\Http\ResponseCore;
  5. /**
  6. * Class ListPartsResultTest
  7. * @package OSS\Tests
  8. */
  9. class ListPartsResultTest extends \PHPUnit_Framework_TestCase
  10. {
  11. private $validXml = <<<BBBB
  12. <?xml version="1.0" encoding="UTF-8"?>
  13. <ListPartsResult xmlns="http://doc.oss-cn-hangzhou.aliyuncs.com">
  14. <Bucket>multipart_upload</Bucket>
  15. <Key>multipart.data</Key>
  16. <UploadId>0004B999EF5A239BB9138C6227D69F95</UploadId>
  17. <NextPartNumberMarker>5</NextPartNumberMarker>
  18. <MaxParts>1000</MaxParts>
  19. <IsTruncated>false</IsTruncated>
  20. <Part>
  21. <PartNumber>1</PartNumber>
  22. <LastModified>2012-02-23T07:01:34.000Z</LastModified>
  23. <ETag>&quot;3349DC700140D7F86A078484278075A9&quot;</ETag>
  24. <Size>6291456</Size>
  25. </Part>
  26. <Part>
  27. <PartNumber>2</PartNumber>
  28. <LastModified>2012-02-23T07:01:12.000Z</LastModified>
  29. <ETag>&quot;3349DC700140D7F86A078484278075A9&quot;</ETag>
  30. <Size>6291456</Size>
  31. </Part>
  32. <Part>
  33. <PartNumber>5</PartNumber>
  34. <LastModified>2012-02-23T07:02:03.000Z</LastModified>
  35. <ETag>&quot;7265F4D211B56873A381D321F586E4A9&quot;</ETag>
  36. <Size>1024</Size>
  37. </Part>
  38. </ListPartsResult>
  39. BBBB;
  40. public function testParseValidXml()
  41. {
  42. $response = new ResponseCore(array(), $this->validXml, 200);
  43. $result = new ListPartsResult($response);
  44. $listPartsInfo = $result->getData();
  45. $this->assertEquals("multipart_upload", $listPartsInfo->getBucket());
  46. $this->assertEquals("multipart.data", $listPartsInfo->getKey());
  47. $this->assertEquals("0004B999EF5A239BB9138C6227D69F95", $listPartsInfo->getUploadId());
  48. $this->assertEquals(5, $listPartsInfo->getNextPartNumberMarker());
  49. $this->assertEquals(1000, $listPartsInfo->getMaxParts());
  50. $this->assertEquals("false", $listPartsInfo->getIsTruncated());
  51. $this->assertEquals(3, count($listPartsInfo->getListPart()));
  52. $parts = $listPartsInfo->getListPart();
  53. $this->assertEquals(1, $parts[0]->getPartNumber());
  54. $this->assertEquals('2012-02-23T07:01:34.000Z', $parts[0]->getLastModified());
  55. $this->assertEquals('"3349DC700140D7F86A078484278075A9"', $parts[0]->getETag());
  56. $this->assertEquals(6291456, $parts[0]->getSize());
  57. }
  58. }