InitiateMultipartUploadResultTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace OSS\Tests;
  3. use OSS\Core\OssException;
  4. use OSS\Result\InitiateMultipartUploadResult;
  5. use OSS\Http\ResponseCore;
  6. class InitiateMultipartUploadResultTest extends \PHPUnit_Framework_TestCase
  7. {
  8. private $validXml = <<<BBBB
  9. <?xml version="1.0" encoding="UTF-8"?>
  10. <InitiateMultipartUploadResult xmlns="http://doc.oss-cn-hangzhou.aliyuncs.com">
  11. <Bucket> multipart_upload</Bucket>
  12. <Key>multipart.data</Key>
  13. <UploadId>0004B9894A22E5B1888A1E29F8236E2D</UploadId>
  14. </InitiateMultipartUploadResult>
  15. BBBB;
  16. private $invalidXml = <<<BBBB
  17. <?xml version="1.0" encoding="UTF-8"?>
  18. <InitiateMultipartUploadResult xmlns="http://doc.oss-cn-hangzhou.aliyuncs.com">
  19. <Bucket> multipart_upload</Bucket>
  20. <Key>multipart.data</Key>
  21. </InitiateMultipartUploadResult>
  22. BBBB;
  23. public function testParseValidXml()
  24. {
  25. $response = new ResponseCore(array(), $this->validXml, 200);
  26. $result = new InitiateMultipartUploadResult($response);
  27. $this->assertEquals("0004B9894A22E5B1888A1E29F8236E2D", $result->getData());
  28. }
  29. public function testParseInvalidXml()
  30. {
  31. $response = new ResponseCore(array(), $this->invalidXml, 200);
  32. try {
  33. $result = new InitiateMultipartUploadResult($response);
  34. $this->assertTrue(false);
  35. } catch (OssException $e) {
  36. }
  37. }
  38. }