Skip to content

Commit b336d36

Browse files
committed
test:modify BucketTest.php
1 parent e9e9d1a commit b336d36

File tree

1 file changed

+163
-1
lines changed

1 file changed

+163
-1
lines changed

tests/Qiniu/Tests/BucketTest.php

Lines changed: 163 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Qiniu\Tests;
33

4+
use Qiniu\Config;
45
use Qiniu\Storage\BucketManager;
56

67
class BucketTest extends \PHPUnit_Framework_TestCase
@@ -10,6 +11,7 @@ class BucketTest extends \PHPUnit_Framework_TestCase
1011
protected $bucketName;
1112
protected $key;
1213
protected $key2;
14+
protected $customCallbackURL;
1315

1416
protected function setUp()
1517
{
@@ -20,8 +22,12 @@ protected function setUp()
2022
$this->key = $key;
2123
$this->key2 = $key2;
2224

25+
global $customCallbackURL;
26+
$this->customCallbackURL = $customCallbackURL;
27+
2328
global $testAuth;
24-
$this->bucketManager = new BucketManager($testAuth);
29+
$config = new Config();
30+
$this->bucketManager = new BucketManager($testAuth, $config);
2531

2632
global $dummyAuth;
2733
$this->dummyBucketManager = new BucketManager($dummyAuth);
@@ -38,13 +44,140 @@ public function testBuckets()
3844
$this->assertEquals(401, $error->code());
3945
$this->assertNull($list2);
4046
$this->assertNotNull($error->message());
47+
$this->assertNotNull($error->getResponse());
48+
}
49+
50+
public function testListbuckets()
51+
{
52+
list($ret, $error) = $this->bucketManager->listbuckets('z0');
53+
$this->assertNotNull($ret);
54+
$this->assertNull($error);
55+
}
56+
57+
public function testCreateBucket()
58+
{
59+
list($ret, $error) = $this->bucketManager->createBucket('phpsdk-ci-test');
60+
$this->assertNotNull($ret);
61+
$this->assertNull($error);
62+
}
63+
64+
public function testDeleteBucket()
65+
{
66+
list($ret, $error) = $this->bucketManager->deleteBucket('phpsdk-ci-test');
67+
$this->assertNotNull($ret);
68+
$this->assertNull($error);
69+
}
70+
71+
public function testDomains()
72+
{
73+
list($ret, $error) = $this->bucketManager->domains($this->bucketName);
74+
$this->assertNotNull($ret);
75+
$this->assertNull($error);
76+
}
77+
78+
public function testBucketInfo()
79+
{
80+
list($ret, $error) = $this->bucketManager->bucketInfo($this->bucketName);
81+
$this->assertNotNull($ret);
82+
$this->assertNull($error);
83+
}
84+
85+
public function testBucketInfos()
86+
{
87+
list($ret, $error) = $this->bucketManager->bucketInfos('z0');
88+
$this->assertNotNull($ret);
89+
$this->assertNull($error);
4190
}
4291

4392
public function testList()
4493
{
4594
list($ret, $error) = $this->bucketManager->listFiles($this->bucketName, null, null, 10);
4695
$this->assertNotNull($ret['items'][0]);
4796
$this->assertNotNull($ret['marker']);
97+
$this->assertNull($error);
98+
}
99+
100+
public function testListFilesv2()
101+
{
102+
list($ret, $error) = $this->bucketManager->listFilesv2($this->bucketName, null, null, 10);
103+
$this->assertNotNull($ret);
104+
$this->assertNull($error);
105+
}
106+
107+
public function testBucketLifecycleRule()
108+
{
109+
list($ret, $error) = $this->bucketManager->bucketLifecycleRule($this->bucketName, 'demo', 'test', 80, 70);
110+
$this->assertNotNull($ret);
111+
$this->assertNull($error);
112+
}
113+
114+
public function testGetbucketLifecycleRule()
115+
{
116+
list($ret, $error) = $this->bucketManager->getBucketLifecycleRules($this->bucketName);
117+
$this->assertNotNull($ret);
118+
$this->assertNull($error);
119+
}
120+
121+
public function testUpdatebucketLifecycleRule()
122+
{
123+
list($ret, $error) = $this->bucketManager->updateBucketLifecycleRule(
124+
$this->bucketName,
125+
'demo',
126+
'testupdate',
127+
80,
128+
70
129+
);
130+
$this->assertNotNull($ret);
131+
$this->assertNull($error);
132+
}
133+
134+
public function testDeleteBucketLifecycleRule()
135+
{
136+
list($ret, $error) = $this->bucketManager->deleteBucketLifecycleRule($this->bucketName, 'demo');
137+
$this->assertNotNull($ret);
138+
$this->assertNull($error);
139+
}
140+
141+
public function testPutBucketEvent()
142+
{
143+
list($ret, $error) = $this->bucketManager->putBucketEvent(
144+
$this->bucketName,
145+
'bucketevent',
146+
'test',
147+
'img',
148+
array('copy'),
149+
$this->customCallbackURL
150+
);
151+
$this->assertNotNull($ret);
152+
$this->assertNull($error);
153+
}
154+
155+
public function testUpdateBucketEvent()
156+
{
157+
list($ret, $error) = $this->bucketManager->updateBucketEvent(
158+
$this->bucketName,
159+
'bucketevent',
160+
'test',
161+
'video',
162+
array('copy'),
163+
$this->customCallbackURL
164+
);
165+
$this->assertNotNull($ret);
166+
$this->assertNull($error);
167+
}
168+
169+
public function testGetBucketEvent()
170+
{
171+
list($ret, $error) = $this->bucketManager->getBucketEvents($this->bucketName);
172+
$this->assertNotNull($ret);
173+
$this->assertNull($error);
174+
}
175+
176+
public function testDeleteBucketEvent()
177+
{
178+
list($ret, $error) = $this->bucketManager->deleteBucketEvent($this->bucketName, 'bucketevent');
179+
$this->assertNotNull($ret);
180+
$this->assertNull($error);
48181
}
49182

50183
public function testStat()
@@ -162,6 +295,35 @@ public function testFetch()
162295
$this->assertNull($error);
163296
}
164297

298+
public function testAsynchFetch()
299+
{
300+
list($ret, $error) = $this->bucketManager->asynchFetch(
301+
'http://devtools.qiniu.com/qiniu.png',
302+
$this->bucketName,
303+
null,
304+
'qiniu.png'
305+
);
306+
$this->assertArrayHasKey('id', $ret);
307+
$this->assertNull($error);
308+
309+
list($ret, $error) = $this->bucketManager->asynchFetch(
310+
'http://devtools.qiniu.com/qiniu.png',
311+
$this->bucketName,
312+
null,
313+
''
314+
);
315+
$this->assertArrayHasKey('id', $ret);
316+
$this->assertNull($error);
317+
318+
list($ret, $error) = $this->bucketManager->asynchFetch(
319+
'http://devtools.qiniu.com/qiniu.png',
320+
$this->bucketName
321+
);
322+
$this->assertArrayHasKey('id', $ret);
323+
$this->assertNull($error);
324+
}
325+
326+
165327
public function testBatchCopy()
166328
{
167329
$key = 'copyto' . rand();

0 commit comments

Comments
 (0)