Skip to content

Commit bc4c0bc

Browse files
committed
fix test cases to adapt to the new interface
1 parent c4b3ccc commit bc4c0bc

File tree

5 files changed

+38
-103
lines changed

5 files changed

+38
-103
lines changed

tests/Qiniu/Tests/BucketTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public function testBuckets()
4141

4242
public function testList()
4343
{
44-
list($items, $marker, $error) = $this->bucketManager->listFiles($this->bucketName, null, null, 2);
45-
$this->assertNotNull($items[0]);
46-
$this->assertNotNull($marker);
44+
list($ret, $error) = $this->bucketManager->listFiles($this->bucketName, null, null, 10);
45+
$this->assertNotNull($ret['items'][0]);
46+
$this->assertNotNull($ret['marker']);
4747
}
4848

4949
public function testStat()

tests/Qiniu/Tests/PfopTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public function testPfop()
1111
global $testAuth;
1212
$bucket = 'testres';
1313
$key = 'sintel_trailer.mp4';
14-
$pfop = new PersistentFop($testAuth, $bucket);
15-
14+
$pfop = new PersistentFop($testAuth, null);
15+
1616
$fops = 'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240';
17-
list($id, $error) = $pfop->execute($key, $fops);
17+
list($id, $error) = $pfop->execute($bucket, $key, $fops);
1818
$this->assertNull($error);
19-
list($status, $error) = PersistentFop::status($id);
19+
list($status, $error) = $pfop->status($id);
2020
$this->assertNotNull($status);
2121
$this->assertNull($error);
2222
}
@@ -28,15 +28,15 @@ public function testPfops()
2828
$bucket = 'testres';
2929
$key = 'sintel_trailer.mp4';
3030
$fops = array(
31-
'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240',
32-
'vframe/jpg/offset/7/w/480/h/360',
33-
);
34-
$pfop = new PersistentFop($testAuth, $bucket);
31+
'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240',
32+
'vframe/jpg/offset/7/w/480/h/360',
33+
);
34+
$pfop = new PersistentFop($testAuth, null);
3535

36-
list($id, $error) = $pfop->execute($key, $fops);
36+
list($id, $error) = $pfop->execute($bucket, $key, $fops);
3737
$this->assertNull($error);
3838

39-
list($status, $error) = PersistentFop::status($id);
39+
list($status, $error) = $pfop->status($id);
4040
$this->assertNotNull($status);
4141
$this->assertNull($error);
4242
}
@@ -46,7 +46,7 @@ public function testMkzip()
4646
global $testAuth;
4747
$bucket = 'phpsdk';
4848
$key = 'php-logo.png';
49-
$pfop = new PersistentFop($testAuth, $bucket);
49+
$pfop = new PersistentFop($testAuth, null);
5050

5151
$url1 = 'http://phpsdk.qiniudn.com/php-logo.png';
5252
$url2 = 'http://phpsdk.qiniudn.com/php-sdk.html';
@@ -56,10 +56,10 @@ public function testMkzip()
5656
$fops .= '/url/' . \Qiniu\base64_urlSafeEncode($url2);
5757
$fops .= '|saveas/' . \Qiniu\base64_urlSafeEncode("$bucket:$zipKey");
5858

59-
list($id, $error) = $pfop->execute($key, $fops);
59+
list($id, $error) = $pfop->execute($bucket, $key, $fops);
6060
$this->assertNull($error);
6161

62-
list($status, $error) = PersistentFop::status($id);
62+
list($status, $error) = $pfop->status($id);
6363
$this->assertNotNull($status);
6464
$this->assertNull($error);
6565
}

tests/Qiniu/Tests/ResumeUpTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ResumeUpTest extends \PHPUnit_Framework_TestCase
1010
{
1111
protected $bucketName;
1212
protected $auth;
13+
1314
protected function setUp()
1415
{
1516
global $bucketName;
@@ -24,7 +25,7 @@ public function test4ML()
2425
$key = 'resumePutFile4ML';
2526
$upManager = new UploadManager();
2627
$token = $this->auth->uploadToken($this->bucketName, $key);
27-
$tempFile = qiniuTempFile(4*1024*1024+10);
28+
$tempFile = qiniuTempFile(4 * 1024 * 1024 + 10);
2829
list($ret, $error) = $upManager->putFile($token, $key, $tempFile);
2930
$this->assertNull($error);
3031
$this->assertNotNull($ret['hash']);
@@ -34,16 +35,17 @@ public function test4ML()
3435
public function test4ML2()
3536
{
3637
$key = 'resumePutFile4ML';
37-
$zone = new Zone('http://up.fake.qiniu.com', 'http://up.qiniu.com');
38+
$zone = new Zone(array('up.fake.qiniu.com'), array('up.qiniup.com'));
3839
$cfg = new Config($zone);
3940
$upManager = new UploadManager($cfg);
4041
$token = $this->auth->uploadToken($this->bucketName, $key);
41-
$tempFile = qiniuTempFile(4*1024*1024+10);
42+
$tempFile = qiniuTempFile(4 * 1024 * 1024 + 10);
4243
list($ret, $error) = $upManager->putFile($token, $key, $tempFile);
4344
$this->assertNull($error);
4445
$this->assertNotNull($ret['hash']);
4546
unlink($tempFile);
4647
}
48+
4749
// public function test8M()
4850
// {
4951
// $key = 'resumePutFile8M';

tests/Qiniu/Tests/ZoneTest.php

Lines changed: 13 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -35,93 +35,26 @@ protected function setUp()
3535

3636
public function testUpHosts()
3737
{
38+
$zone = Zone::QueryZone($this->ak, $this->bucketName);
39+
print_r($zone);
40+
$this->assertContains('upload.qiniup.com', $zone->cdnUpHosts);
3841

39-
// test nb http
40-
list($upHosts, $err) = $this->zone->getUpHosts($this->ak, $this->bucketName);
41-
$this->assertNull($err);
42-
$this->assertEquals('http://up.qiniu.com', $upHosts[0]);
43-
$this->assertEquals('http://upload.qiniu.com', $upHosts[1]);
42+
$zone = Zone::QueryZone($this->ak, $this->bucketNameBC);
43+
$this->assertContains('upload-z1.qiniup.com', $zone->cdnUpHosts);
4444

45-
// test bc http
46-
list($upHosts, $err) = $this->zone->getUpHosts($this->ak, $this->bucketNameBC);
47-
$this->assertNull($err);
48-
$this->assertEquals('http://up-z1.qiniu.com', $upHosts[0]);
49-
$this->assertEquals('http://upload-z1.qiniu.com', $upHosts[1]);
50-
51-
// test na http
52-
list($upHosts, $err) = $this->zone->getUpHosts($this->ak, $this->bucketNameNA);
53-
$this->assertNull($err);
54-
$this->assertEquals('http://up-na0.qiniu.com', $upHosts[0]);
55-
56-
// test nb https
57-
list($upHosts, $err) = $this->zoneHttps->getUpHosts($this->ak, $this->bucketName);
58-
$this->assertNull($err);
59-
$this->assertEquals('https://up.qbox.me', $upHosts[0]);
60-
61-
// test bc https
62-
list($upHosts, $err) = $this->zoneHttps->getUpHosts($this->ak, $this->bucketNameBC);
63-
$this->assertNull($err);
64-
$this->assertEquals('https://up-z1.qbox.me', $upHosts[0]);
65-
66-
// test na https
67-
list($upHosts, $err) = $this->zoneHttps->getUpHosts($this->ak, $this->bucketNameNA);
68-
$this->assertNull($err);
69-
$this->assertEquals('https://up-na0.qbox.me', $upHosts[0]);
70-
}
71-
72-
public function testUpHostByToken()
73-
{
74-
$uptoken_bc = 'QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm:bl77a3xPdTyBNYFGVRy
75-
oIQNyp_s=:eyJzY29wZSI6InBocHNkay1iYyIsImRlYWRsaW5lIjoxNDcwNzI1MzE1LCJ1cEhvc
76-
3RzIjpbImh0dHA6XC9cL3VwLXoxLnFpbml1LmNvbSIsImh0dHA6XC9cL3VwbG9hZC16MS5xaW5p
77-
dS5jb20iLCItSCB1cC16MS5xaW5pdS5jb20gaHR0cDpcL1wvMTA2LjM4LjIyNy4yNyJdfQ==';
78-
79-
list($upHost, $err) = $this->zone->getUpHostByToken($uptoken_bc);
80-
$this->assertEquals('http://up-z1.qiniu.com', $upHost);
81-
$this->assertEquals(null, $err);
82-
83-
list($upHostBackup, $err) = $this->zone->getBackupUpHostByToken($uptoken_bc);
84-
$this->assertEquals('http://upload-z1.qiniu.com', $upHostBackup);
85-
$this->assertEquals(null, $err);
86-
87-
88-
$uptoken_bc_https = 'QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm:7I47O-vFcN5TKO
89-
6D7cobHPVkyIA=:eyJzY29wZSI6InBocHNkay1iYyIsImRlYWRsaW5lIjoxNDcwNzIyNzQ1LCJ1c
90-
Ehvc3RzIjpbImh0dHBzOlwvXC91cC16MS5xYm94Lm1lIl19';
91-
list($upHost, $err) = $this->zoneHttps->getUpHostByToken($uptoken_bc_https);
92-
$this->assertEquals('https://up-z1.qbox.me', $upHost);
93-
$this->assertEquals(null, $err);
94-
95-
list($upHostBackup, $err) = $this->zoneHttps->getBackupUpHostByToken($uptoken_bc_https);
96-
$this->assertEquals('https://upload-z1.qbox.me', $upHostBackup);
97-
$this->assertEquals(null, $err);
45+
$zone = Zone::QueryZone($this->ak, $this->bucketNameNA);
46+
$this->assertContains('upload-na0.qiniup.com', $zone->cdnUpHosts);
9847
}
9948

10049
public function testIoHosts()
10150
{
51+
$zone = Zone::QueryZone($this->ak, $this->bucketName);
52+
$this->assertEquals($zone->iovipHost, 'iovip.qbox.me');
10253

103-
// test nb http
104-
$ioHost = $this->zone->getIoHost($this->ak, $this->bucketName);
105-
$this->assertEquals('http://iovip.qbox.me', $ioHost);
106-
107-
// test bc http
108-
$ioHost = $this->zone->getIoHost($this->ak, $this->bucketNameBC);
109-
$this->assertEquals('http://iovip-z1.qbox.me', $ioHost);
110-
111-
// test na http
112-
$ioHost = $this->zone->getIoHost($this->ak, $this->bucketNameNA);
113-
$this->assertEquals('http://iovip-na0.qbox.me', $ioHost);
114-
115-
// test nb https
116-
$ioHost = $this->zoneHttps->getIoHost($this->ak, $this->bucketName);
117-
$this->assertEquals('https://iovip.qbox.me', $ioHost);
118-
119-
// test bc https
120-
$ioHost = $this->zoneHttps->getIoHost($this->ak, $this->bucketNameBC);
121-
$this->assertEquals('https://iovip-z1.qbox.me', $ioHost);
54+
$zone = Zone::QueryZone($this->ak, $this->bucketNameBC);
55+
$this->assertEquals($zone->iovipHost, 'iovip-z1.qbox.me');
12256

123-
// test na https
124-
$ioHost = $this->zoneHttps->getIoHost($this->ak, $this->bucketNameNA);
125-
$this->assertEquals('https://iovip-na0.qbox.me', $ioHost);
57+
$zone = Zone::QueryZone($this->ak, $this->bucketNameNA);
58+
$this->assertEquals($zone->iovipHost, 'iovip-na0.qbox.me');
12659
}
12760
}

tests/bootstrap.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
// @codingStandardsIgnoreFile
3-
require_once __DIR__.'/../vendor/autoload.php';
3+
require_once __DIR__.'/../autoload.php';
44

55
use Qiniu\Auth;
66

7-
$accessKey = getenv('QINIU_SDK_ENV_ACCESSKEY');
8-
$secretKey = getenv('QINIU_SDK_ENV_SECRETKEY');
7+
$accessKey = getenv('QINIU_ACCESS_KEY');
8+
$secretKey = getenv('QINIU_SECRET_KEY');
99
$testAuth = new Auth($accessKey, $secretKey);
1010

1111
$bucketName = 'phpsdk';
@@ -20,7 +20,7 @@
2020
$dummyAuth = new Auth($dummyAccessKey, $dummySecretKey);
2121

2222
//cdn
23-
$timestampAntiLeechEncryptKey = getenv('QINIU_SDK_ENV_TIMESTAMP_ENCRPTKEY');
23+
$timestampAntiLeechEncryptKey = getenv('QINIU_TIMESTAMP_ENCRPTKEY');
2424
$customDomain = "http://phpsdk.qiniuts.com";
2525

2626
$tid = getenv('TRAVIS_JOB_NUMBER');

0 commit comments

Comments
 (0)