ResumeUpTest.php 1.8 KB

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