@@ -35,6 +35,16 @@ public function testFromPutBucketLogging()
3535 $ this ->assertEquals ('bucket-123 ' , $ input ->getBucket ());
3636 $ xml = <<<BBB
3737<?xml version="1.0" encoding="UTF-8"?><BucketLoggingStatus><LoggingEnabled><TargetBucket>TargetBucket</TargetBucket><TargetPrefix>TargetPrefix</TargetPrefix></LoggingEnabled></BucketLoggingStatus>
38+ BBB ;
39+ $ this ->assertEquals ($ xml , $ this ->cleanXml ($ input ->getBody ()->getContents ()));
40+
41+ $ request = new Models \PutBucketLoggingRequest ('bucket-123 ' , new Models \BucketLoggingStatus (new Models \LoggingEnabled (
42+ targetBucket: 'TargetBucket ' , targetPrefix: 'TargetPrefix ' , loggingRole: 'AliyunOSSLoggingDefaultRole '
43+ )));
44+ $ input = BucketLogging::fromPutBucketLogging ($ request );
45+ $ this ->assertEquals ('bucket-123 ' , $ input ->getBucket ());
46+ $ xml = <<<BBB
47+ <?xml version="1.0" encoding="UTF-8"?><BucketLoggingStatus><LoggingEnabled><TargetBucket>TargetBucket</TargetBucket><TargetPrefix>TargetPrefix</TargetPrefix><LoggingRole>AliyunOSSLoggingDefaultRole</LoggingRole></LoggingEnabled></BucketLoggingStatus>
3848BBB ;
3949 $ this ->assertEquals ($ xml , $ this ->cleanXml ($ input ->getBody ()->getContents ()));
4050 }
@@ -111,6 +121,39 @@ public function testToGetBucketLogging()
111121 $ this ->assertEquals ('application/xml ' , $ result ->headers ['content-type ' ]);
112122 $ this ->assertEquals ('bucket-log ' , $ result ->bucketLoggingStatus ->loggingEnabled ->targetBucket );
113123 $ this ->assertEquals ('prefix-access_log ' , $ result ->bucketLoggingStatus ->loggingEnabled ->targetPrefix );
124+
125+
126+ $ output = new OperationOutput ();
127+ $ result = BucketLogging::toGetBucketLogging ($ output );
128+ $ this ->assertEquals ('' , $ result ->status );
129+ $ this ->assertEquals (0 , $ result ->statusCode );
130+ $ this ->assertEquals ('' , $ result ->requestId );
131+ $ this ->assertEquals (0 , count ($ result ->headers ));
132+
133+ $ body = '<?xml version="1.0" encoding="UTF-8"?>
134+ <BucketLoggingStatus>
135+ <LoggingEnabled>
136+ <TargetBucket>bucket-log</TargetBucket>
137+ <TargetPrefix>prefix-access_log</TargetPrefix>
138+ <LoggingRole>AliyunOSSLoggingDefaultRole</LoggingRole>
139+ </LoggingEnabled>
140+ </BucketLoggingStatus> ' ;
141+ $ output = new OperationOutput (
142+ 'OK ' ,
143+ 200 ,
144+ ['x-oss-request-id ' => '123 ' , 'content-type ' => 'application/xml ' ],
145+ Utils::streamFor ($ body )
146+ );
147+ $ result = BucketLogging::toGetBucketLogging ($ output );
148+ $ this ->assertEquals ('OK ' , $ result ->status );
149+ $ this ->assertEquals (200 , $ result ->statusCode );
150+ $ this ->assertEquals ('123 ' , $ result ->requestId );
151+ $ this ->assertEquals (2 , count ($ result ->headers ));
152+ $ this ->assertEquals ('123 ' , $ result ->headers ['x-oss-request-id ' ]);
153+ $ this ->assertEquals ('application/xml ' , $ result ->headers ['content-type ' ]);
154+ $ this ->assertEquals ('bucket-log ' , $ result ->bucketLoggingStatus ->loggingEnabled ->targetBucket );
155+ $ this ->assertEquals ('prefix-access_log ' , $ result ->bucketLoggingStatus ->loggingEnabled ->targetPrefix );
156+ $ this ->assertEquals ('AliyunOSSLoggingDefaultRole ' , $ result ->bucketLoggingStatus ->loggingEnabled ->loggingRole );
114157 }
115158
116159 public function testFromDeleteBucketLogging ()
0 commit comments