OssClientBucketWebsiteTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace OSS\Tests;
  3. use OSS\Core\OssException;
  4. use OSS\Model\WebsiteConfig;
  5. require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
  6. class OssClientBucketWebsiteTest extends TestOssClientBase
  7. {
  8. public function testBucket()
  9. {
  10. $websiteConfig = new WebsiteConfig("index.html", "error.html");
  11. try {
  12. $this->ossClient->putBucketWebsite($this->bucket, $websiteConfig);
  13. } catch (OssException $e) {
  14. var_dump($e->getMessage());
  15. $this->assertTrue(false);
  16. }
  17. try {
  18. Common::waitMetaSync();
  19. $websiteConfig2 = $this->ossClient->getBucketWebsite($this->bucket);
  20. $this->assertEquals($websiteConfig->serializeToXml(), $websiteConfig2->serializeToXml());
  21. } catch (OssException $e) {
  22. $this->assertTrue(false);
  23. }
  24. try {
  25. Common::waitMetaSync();
  26. $this->ossClient->deleteBucketWebsite($this->bucket);
  27. } catch (OssException $e) {
  28. $this->assertTrue(false);
  29. }
  30. try {
  31. Common::waitMetaSync();
  32. $websiteConfig3 = $this->ossClient->getBucketLogging($this->bucket);
  33. $this->assertNotEquals($websiteConfig->serializeToXml(), $websiteConfig3->serializeToXml());
  34. } catch (OssException $e) {
  35. $this->assertTrue(false);
  36. }
  37. }
  38. }