PfopTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Qiniu\Tests;
  3. use Qiniu\Processing\Operation;
  4. use Qiniu\Processing\PersistentFop;
  5. class PfopTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testPfop()
  8. {
  9. global $testAuth;
  10. $bucket = 'testres';
  11. $key = 'sintel_trailer.mp4';
  12. $pfop = new PersistentFop($testAuth, $bucket);
  13. $fops = 'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240';
  14. list($id, $error) = $pfop->execute($key, $fops);
  15. $this->assertNull($error);
  16. list($status, $error) = PersistentFop::status($id);
  17. $this->assertNotNull($status);
  18. var_dump($status);
  19. $this->assertNull($error);
  20. }
  21. public function testPfops()
  22. {
  23. global $testAuth;
  24. $bucket = 'testres';
  25. $key = 'sintel_trailer.mp4';
  26. $fops = array(
  27. 'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240',
  28. 'vframe/jpg/offset/7/w/480/h/360',
  29. );
  30. $pfop = new PersistentFop($testAuth, $bucket);
  31. list($id, $error) = $pfop->execute($key, $fops);
  32. $this->assertNull($error);
  33. list($status, $error) = PersistentFop::status($id);
  34. $this->assertNotNull($status);
  35. $this->assertNull($error);
  36. }
  37. public function testMkzip()
  38. {
  39. global $testAuth;
  40. $bucket = 'phpsdk';
  41. $key = 'php-logo.png';
  42. $pfop = new PersistentFop($testAuth, $bucket);
  43. $url1 = 'http://phpsdk.qiniudn.com/php-logo.png';
  44. $url2 = 'http://phpsdk.qiniudn.com/php-sdk.html';
  45. $zipKey = 'test.zip';
  46. $fops = 'mkzip/2/url/' . \Qiniu\base64_urlSafeEncode($url1);
  47. $fops .= '/url/' . \Qiniu\base64_urlSafeEncode($url2);
  48. $fops .= '|saveas/' . \Qiniu\base64_urlSafeEncode("$bucket:$zipKey");
  49. list($id, $error) = $pfop->execute($key, $fops);
  50. $this->assertNull($error);
  51. list($status, $error) = PersistentFop::status($id);
  52. $this->assertNotNull($status);
  53. $this->assertNull($error);
  54. }
  55. }