OssClientBucketLoggingTest.php 1.4 KB

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