@@ -32,8 +32,8 @@ protected function tearDown() {
3232 /**********************************
3333 * TestBucket
3434 **********************************/
35-
36- /*
35+
36+ /*
3737 * put bucket,bucket已经存在
3838 * BucketAlreadyOwnedByYou
3939 * 409
@@ -47,6 +47,62 @@ public function testCreateExistingBucket()
4747 }
4848 }
4949
50+ /*
51+ * put bucket, 创建所有region的bucket
52+ * 409
53+ */
54+ public function testValidRegionBucket ()
55+ {
56+ $ regionlist = array ('cn-east ' ,'ap-shanghai ' ,
57+ 'cn-south ' ,'ap-guangzhou ' ,
58+ 'cn-north ' ,'ap-beijing-1 ' ,
59+ 'cn-south-2 ' ,'ap-guangzhou-2 ' ,
60+ 'cn-southwest ' ,'ap-chengdu ' ,
61+ 'sg ' ,'ap-singapore ' ,
62+ 'tj ' ,'ap-beijing-1 ' ,
63+ 'bj ' ,'ap-beijing ' ,
64+ 'sh ' ,'ap-shanghai ' ,
65+ 'gz ' ,'ap-guangzhou ' ,
66+ 'cd ' ,'ap-chengdu ' ,
67+ 'sgp ' ,'ap-singapore ' );
68+ foreach ($ regionlist as $ region ) {
69+ try {
70+
71+ $ this ->cosClient = new Client (array ('region ' => $ region ,
72+ 'credentials ' => array (
73+ 'appId ' => getenv ('COS_APPID ' ),
74+ 'secretId ' => getenv ('COS_KEY ' ),
75+ 'secretKey ' => getenv ('COS_SECRET ' ))));
76+ $ this ->cosClient ->createBucket (['Bucket ' => $ this ->bucket ]);
77+ } catch (ServiceResponseException $ e ) {
78+ $ this ->assertEquals ([$ e ->getStatusCode ()], [409 ]);
79+ }
80+ }
81+ }
82+
83+ /*
84+ * put bucket, 不合法的region名
85+ * 409
86+ */
87+ public function testInvalidRegionBucket ()
88+ {
89+ $ regionlist = array ('cn-east-2 ' ,'ap-shanghai-3 ' );
90+ foreach ($ regionlist as $ region ) {
91+ try {
92+ $ this ->cosClient = new Client (array ('region ' => $ region ,
93+ 'credentials ' => array (
94+ 'appId ' => getenv ('COS_APPID ' ),
95+ 'secretId ' => getenv ('COS_KEY ' ),
96+ 'secretKey ' => getenv ('COS_SECRET ' ))));
97+ $ this ->cosClient ->createBucket (['Bucket ' => $ this ->bucket ]);
98+ } catch (ServiceResponseException $ e ) {
99+ $ this ->assertFalse (TRUE );
100+ } catch (\GuzzleHttp \Exception \ConnectException $ e ) {
101+ $ this ->assertTrue (TRUE );
102+ }
103+ }
104+ }
105+
50106 /*
51107 * put bucket,bucket名称非法
52108 * InvalidBucketName
0 commit comments