public function testConstructValidConfig()
 {
     $lifecycleConfig = new LifecycleConfig();
     $actions = array();
     $actions[] = new LifecycleAction("Expiration", "Days", 3);
     $lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions);
     $lifecycleConfig->addRule($lifecycleRule);
     $actions = array();
     $actions[] = new LifecycleAction("Expiration", "Date", '2022-10-12T00:00:00.000Z');
     $actions[] = new LifecycleAction("Expiration2", "Date", '2022-10-12T00:00:00.000Z');
     $lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions);
     $lifecycleConfig->addRule($lifecycleRule);
     try {
         $lifecycleConfig->addRule(null);
         $this->assertFalse(true);
     } catch (Exception $e) {
         $this->assertEquals('lifecycleRule is null', $e->getMessage());
     }
     $this->assertEquals($this->cleanXml(strval($lifecycleConfig)), $this->cleanXml($this->validLifecycle));
 }
 public function testBucket()
 {
     $lifecycleConfig = new LifecycleConfig();
     $actions = array();
     $actions[] = new LifecycleAction("Expiration", "Days", 3);
     $lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions);
     $lifecycleConfig->addRule($lifecycleRule);
     $actions = array();
     $actions[] = new LifecycleAction("Expiration", "Date", '2022-10-12T00:00:00.000Z');
     $lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions);
     $lifecycleConfig->addRule($lifecycleRule);
     try {
         $this->ossClient->putBucketLifecycle($this->bucket, $lifecycleConfig);
     } catch (Exception $e) {
         $this->assertTrue(false);
     }
     try {
         sleep(5);
         $lifecycleConfig2 = $this->ossClient->getBucketLifecycle($this->bucket);
         $this->assertEquals($lifecycleConfig->serializeToXml(), $lifecycleConfig2->serializeToXml());
     } catch (Exception $e) {
         $this->assertTrue(false);
     }
     try {
         $this->ossClient->deleteBucketLifecycle($this->bucket);
     } catch (Exception $e) {
         $this->assertTrue(false);
     }
     try {
         sleep(3);
         $lifecycleConfig3 = $this->ossClient->getBucketLifecycle($this->bucket);
         $this->assertNotEquals($lifecycleConfig->serializeToXml(), $lifecycleConfig3->serializeToXml());
     } catch (Exception $e) {
         $this->assertTrue(false);
     }
 }