ResumeUpTest.php
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace Qiniu\Tests;
use Qiniu\Storage\ResumeUploader;
use Qiniu\Storage\UploadManager;
use Qiniu\Config;
use Qiniu\Zone;
class ResumeUpTest extends \PHPUnit_Framework_TestCase
{
protected $bucketName;
protected $auth;
protected function setUp()
{
global $bucketName;
$this->bucketName = $bucketName;
global $testAuth;
$this->auth = $testAuth;
}
public function test4ML()
{
$key = 'resumePutFile4ML';
$upManager = new UploadManager();
$token = $this->auth->uploadToken($this->bucketName, $key);
$tempFile = qiniuTempFile(4 * 1024 * 1024 + 10);
list($ret, $error) = $upManager->putFile($token, $key, $tempFile);
$this->assertNull($error);
$this->assertNotNull($ret['hash']);
unlink($tempFile);
}
public function test4ML2()
{
$key = 'resumePutFile4ML';
$zone = new Zone(array('up.fake.qiniu.com'), array('up.qiniup.com'));
$cfg = new Config($zone);
$upManager = new UploadManager($cfg);
$token = $this->auth->uploadToken($this->bucketName, $key);
$tempFile = qiniuTempFile(4 * 1024 * 1024 + 10);
list($ret, $error) = $upManager->putFile($token, $key, $tempFile);
$this->assertNull($error);
$this->assertNotNull($ret['hash']);
unlink($tempFile);
}
// public function test8M()
// {
// $key = 'resumePutFile8M';
// $upManager = new UploadManager();
// $token = $this->auth->uploadToken($this->bucketName, $key);
// $tempFile = qiniuTempFile(8*1024*1024+10);
// list($ret, $error) = $upManager->putFile($token, $key, $tempFile);
// $this->assertNull($error);
// $this->assertNotNull($ret['hash']);
// unlink($tempFile);
// }
}