diff --git a/.travis.yml b/.travis.yml index f5dbf7e5..cada8cd0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ php: - 5.5 - 5.6 - 7.0 - - 7.2 before_script: - export QINIU_TEST_ENV="travis" diff --git a/composer.json b/composer.json index 32078362..52544fe7 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "~8.0", + "phpunit/phpunit": "~4.0", "squizlabs/php_codesniffer": "~2.3" }, "autoload": { diff --git a/src/Qiniu/Config.php b/src/Qiniu/Config.php index 94c43f65..ec75df68 100644 --- a/src/Qiniu/Config.php +++ b/src/Qiniu/Config.php @@ -3,7 +3,7 @@ final class Config { - const SDK_VER = '7.3.0'; + const SDK_VER = '7.2.9'; const BLOCK_SIZE = 4194304; //4*1024*1024 分块上传块大小,该参数为接口规格,不能修改 diff --git a/src/Qiniu/Storage/FormUploader.php b/src/Qiniu/Storage/FormUploader.php index 40928df1..d87756a0 100644 --- a/src/Qiniu/Storage/FormUploader.php +++ b/src/Qiniu/Storage/FormUploader.php @@ -31,8 +31,7 @@ public static function put( $config, $params, $mime, - $fname, - $checkCrc + $fname ) { $fields = array('token' => $upToken); if ($key === null) { diff --git a/src/Qiniu/Storage/UploadManager.php b/src/Qiniu/Storage/UploadManager.php index 293be3e9..209df11a 100644 --- a/src/Qiniu/Storage/UploadManager.php +++ b/src/Qiniu/Storage/UploadManager.php @@ -46,8 +46,7 @@ public function put( $data, $params = null, $mime = 'application/octet-stream', - $fname = null, - $checkCrc = false + $fname = null ) { $params = self::trimParams($params); @@ -58,8 +57,7 @@ public function put( $this->config, $params, $mime, - $fname, - $checkCrc + $fname ); } @@ -110,8 +108,7 @@ public function putFile( $this->config, $params, $mime, - basename($filePath), - $checkCrc + basename($filePath) ); } diff --git a/tests/Qiniu/Tests/AuthTest.php b/tests/Qiniu/Tests/AuthTest.php old mode 100644 new mode 100755 index f53b57f3..712cbd57 --- a/tests/Qiniu/Tests/AuthTest.php +++ b/tests/Qiniu/Tests/AuthTest.php @@ -5,18 +5,17 @@ function time() { return isset($_SERVER['override_qiniu_auth_time']) - ? 2234567890 + ? 1234567890 : \time(); } } namespace Qiniu\Tests { use Qiniu\Auth; - use PHPUnit\Framework\TestCase; // @codingStandardsIgnoreEnd - class AuthTest extends TestCase + class AuthTest extends \PHPUnit_Framework_TestCase { public function testSign() @@ -30,10 +29,7 @@ public function testSignWithData() { global $dummyAuth; $token = $dummyAuth->signWithData('test'); - $this->assertEquals( - 'abcdefghklmnopq:-jP8eEV9v48MkYiBGs81aDxl60E=:dGVzdA==', - $token - ); + $this->assertEquals('abcdefghklmnopq:-jP8eEV9v48MkYiBGs81aDxl60E=:dGVzdA==', $token); } public function testSignRequest() @@ -43,10 +39,7 @@ public function testSignRequest() $this->assertEquals('abcdefghklmnopq:cFyRVoWrE3IugPIMP5YJFTO-O-Y=', $token); $ctype = 'application/x-www-form-urlencoded'; $token = $dummyAuth->signRequest('http://www.qiniu.com?go=1', 'test', $ctype); - $this->assertEquals( - $token, - 'abcdefghklmnopq:svWRNcacOE-YMsc70nuIYdaa1e4=' - ); + $this->assertEquals($token, 'abcdefghklmnopq:svWRNcacOE-YMsc70nuIYdaa1e4='); } public function testPrivateDownloadUrl() @@ -54,7 +47,7 @@ public function testPrivateDownloadUrl() global $dummyAuth; $_SERVER['override_qiniu_auth_time'] = true; $url = $dummyAuth->privateDownloadUrl('http://www.qiniu.com?go=1'); - $expect = 'http://www.qiniu.com?go=1&e=2234571490&token=abcdefghklmnopq:Hvi3R79Sl6wZy1c331nv0iIFoJk='; + $expect = 'http://www.qiniu.com?go=1&e=1234571490&token=abcdefghklmnopq:8vzBeLZ9W3E4kbBLFLW0Xe0u7v4='; $this->assertEquals($expect, $url); unset($_SERVER['override_qiniu_auth_time']); } @@ -65,10 +58,14 @@ public function testUploadToken() $_SERVER['override_qiniu_auth_time'] = true; $token = $dummyAuth->uploadToken('1', '2', 3600, array('endUser' => 'y')); // @codingStandardsIgnoreStart - $exp = 'abcdefghklmnopq:GracWhW1iGwVL6haVH5dr4gjqeo=:eyJlbmRVc2VyIjoieSIsInNjb3BlIjoiMToyIiwiZGVhZGxpbmUiOjIyMzQ1NzE0OTB9'; + $exp = 'abcdefghklmnopq:yyeexeUkPOROoTGvwBjJ0F0VLEo=:eyJlbmRVc2VyIjoieSIsInNjb3BlIjoiMToyIiwiZGVhZGxpbmUiOjEyMzQ1NzE0OTB9'; // @codingStandardsIgnoreEnd $this->assertEquals($exp, $token); unset($_SERVER['override_qiniu_auth_time']); } + + public function testVerifyCallback() + { + } } } diff --git a/tests/Qiniu/Tests/Base64Test.php b/tests/Qiniu/Tests/Base64Test.php old mode 100644 new mode 100755 index b2f37264..6d633530 --- a/tests/Qiniu/Tests/Base64Test.php +++ b/tests/Qiniu/Tests/Base64Test.php @@ -2,9 +2,8 @@ namespace Qiniu\Tests; use Qiniu; -use PHPUnit\Framework\TestCase; -class Base64Test extends TestCase +class Base64Test extends \PHPUnit_Framework_TestCase { public function testUrlSafe() { diff --git a/tests/Qiniu/Tests/BucketTest.php b/tests/Qiniu/Tests/BucketTest.php old mode 100644 new mode 100755 index 7e8d6454..534d8c2f --- a/tests/Qiniu/Tests/BucketTest.php +++ b/tests/Qiniu/Tests/BucketTest.php @@ -2,9 +2,8 @@ namespace Qiniu\Tests; use Qiniu\Storage\BucketManager; -use PHPUnit\Framework\TestCase; -class BucketTest extends TestCase +class BucketTest extends \PHPUnit_Framework_TestCase { protected $bucketManager; protected $dummyBucketManager; @@ -12,7 +11,7 @@ class BucketTest extends TestCase protected $key; protected $key2; - protected function setUp(): void + protected function setUp() { global $bucketName; global $key; diff --git a/tests/Qiniu/Tests/CdnManagerTest.php b/tests/Qiniu/Tests/CdnManagerTest.php old mode 100644 new mode 100755 index 020c868d..3c45bbdf --- a/tests/Qiniu/Tests/CdnManagerTest.php +++ b/tests/Qiniu/Tests/CdnManagerTest.php @@ -10,15 +10,14 @@ use Qiniu\Cdn\CdnManager; use Qiniu\Http\Client; -use PHPUnit\Framework\TestCase; -class CdnManagerTest extends TestCase +class CdnManagerTest extends \PHPUnit_Framework_TestCase { protected $cdnManager; protected $encryptKey; protected $imgUrl; - protected function setUp(): void + protected function setUp() { global $timestampAntiLeechEncryptKey; global $customDomain; @@ -35,17 +34,8 @@ public function testCreateTimestampAntiLeechUrl() $signUrl = $this->cdnManager->createTimestampAntiLeechUrl($this->imgUrl, $this->encryptKey, 3600); $response = Client::get($signUrl); + $this->assertEquals($response->statusCode, 200); $this->assertNull($response->error); - - $url2 = $this->imgUrl . '?imageInfo'; - $signUrl2 = $this->cdnManager->createTimestampAntiLeechUrl($url2, $this->encryptKey, 3600); - - $response = Client::get($signUrl2); - $imgInfo = $response->json(); - - $this->assertEquals($response->statusCode, 200); - $this->assertEquals($imgInfo['size'], 2196145); - $this->assertNull($response->error); } } diff --git a/tests/Qiniu/Tests/Crc32Test.php b/tests/Qiniu/Tests/Crc32Test.php old mode 100644 new mode 100755 index 3f1ba80a..bfb36da8 --- a/tests/Qiniu/Tests/Crc32Test.php +++ b/tests/Qiniu/Tests/Crc32Test.php @@ -2,9 +2,8 @@ namespace Qiniu\Tests; use Qiniu; -use PHPUnit\Framework\TestCase; -class Crc32Test extends TestCase +class Crc32Test extends \PHPUnit_Framework_TestCase { public function testData() { diff --git a/tests/Qiniu/Tests/DownloadTest.php b/tests/Qiniu/Tests/DownloadTest.php old mode 100644 new mode 100755 index 7a34f45f..82990f2a --- a/tests/Qiniu/Tests/DownloadTest.php +++ b/tests/Qiniu/Tests/DownloadTest.php @@ -2,14 +2,13 @@ namespace Qiniu\Tests; use Qiniu\Http\Client; -use PHPUnit\Framework\TestCase; -class DownloadTest extends TestCase +class DownloadTest extends \PHPUnit_Framework_TestCase { public function test() { global $testAuth; - $base_url = 'http://pojiwyou0.bkt.clouddn.com/demo.png'; + $base_url = 'http://private-res.qiniudn.com/gogopher.jpg'; $private_url = $testAuth->privateDownloadUrl($base_url); $response = Client::get($private_url); $this->assertEquals(200, $response->statusCode); @@ -18,7 +17,7 @@ public function test() public function testFop() { global $testAuth; - $base_url = 'http://pojiwyou0.bkt.clouddn.com/demo.png?imageInfo'; + $base_url = 'http://private-res.qiniudn.com/gogopher.jpg?exif'; $private_url = $testAuth->privateDownloadUrl($base_url); $response = Client::get($private_url); $this->assertEquals(200, $response->statusCode); diff --git a/tests/Qiniu/Tests/EtagTest.php b/tests/Qiniu/Tests/EtagTest.php old mode 100644 new mode 100755 index bee121be..42a14993 --- a/tests/Qiniu/Tests/EtagTest.php +++ b/tests/Qiniu/Tests/EtagTest.php @@ -2,9 +2,8 @@ namespace Qiniu\Tests; use Qiniu\Etag; -use PHPUnit\Framework\TestCase; -class EtagTest extends TestCase +class EtagTest extends \PHPUnit_Framework_TestCase { public function test0M() { diff --git a/tests/Qiniu/Tests/FopTest.php b/tests/Qiniu/Tests/FopTest.php old mode 100644 new mode 100755 index 8a4c5edb..e1ea730e --- a/tests/Qiniu/Tests/FopTest.php +++ b/tests/Qiniu/Tests/FopTest.php @@ -3,14 +3,13 @@ use Qiniu\Processing\Operation; use Qiniu\Processing\PersistentFop; -use PHPUnit\Framework\TestCase; -class FopTest extends TestCase +class FopTest extends \PHPUnit_Framework_TestCase { public function testExifPub() { - $fop = new Operation('7xkv1q.com1.z0.glb.clouddn.com'); - list($exif, $error) = $fop->execute('grape.jpg', 'exif'); + $fop = new Operation('testres.qiniudn.com'); + list($exif, $error) = $fop->execute('gogopher.jpg', 'exif'); $this->assertNull($error); $this->assertNotNull($exif); } @@ -27,12 +26,12 @@ public function testExifPrivate() public function testbuildUrl() { $fops = 'imageView2/2/h/200'; - $fop = new Operation('7xkv1q.com1.z0.glb.clouddn.com'); - $url = $fop->buildUrl('grape.jpg', $fops); - $this->assertEquals($url, 'http://7xkv1q.com1.z0.glb.clouddn.com/grape.jpg?imageView2/2/h/200'); + $fop = new Operation('testres.qiniudn.com'); + $url = $fop->buildUrl('gogopher.jpg', $fops); + $this->assertEquals($url, 'http://testres.qiniudn.com/gogopher.jpg?imageView2/2/h/200'); $fops = array('imageView2/2/h/200', 'imageInfo'); - $url = $fop->buildUrl('grape.jpg', $fops); - $this->assertEquals($url, 'http://7xkv1q.com1.z0.glb.clouddn.com/grape.jpg?imageView2/2/h/200|imageInfo'); + $url = $fop->buildUrl('gogopher.jpg', $fops); + $this->assertEquals($url, 'http://testres.qiniudn.com/gogopher.jpg?imageView2/2/h/200|imageInfo'); } } diff --git a/tests/Qiniu/Tests/FormUpTest.php b/tests/Qiniu/Tests/FormUpTest.php old mode 100644 new mode 100755 index d3d0ecf5..4813eed9 --- a/tests/Qiniu/Tests/FormUpTest.php +++ b/tests/Qiniu/Tests/FormUpTest.php @@ -4,15 +4,14 @@ use Qiniu\Storage\FormUploader; use Qiniu\Storage\UploadManager; use Qiniu\Config; -use PHPUnit\Framework\TestCase; -class FormUpTest extends TestCase +class FormUpTest extends \PHPUnit_Framework_TestCase { protected $bucketName; protected $auth; protected $cfg; - protected function setUp(): void + protected function setUp() { global $bucketName; $this->bucketName = $bucketName; @@ -25,16 +24,7 @@ protected function setUp(): void public function testData() { $token = $this->auth->uploadToken($this->bucketName); - list($ret, $error) = FormUploader::put( - $token, - 'formput', - 'hello world', - $this->cfg, - null, - 'text/plain', - null, - false - ); + list($ret, $error) = FormUploader::put($token, 'formput', 'hello world', $this->cfg, null, 'text/plain', null); $this->assertNull($error); $this->assertNotNull($ret['hash']); } @@ -43,7 +33,7 @@ public function testData2() { $upManager = new UploadManager(); $token = $this->auth->uploadToken($this->bucketName); - list($ret, $error) = $upManager->put($token, 'formput', 'hello world', null, 'text/plain', null, false); + list($ret, $error) = $upManager->put($token, 'formput', 'hello world', null, 'text/plain', null); $this->assertNull($error); $this->assertNotNull($ret['hash']); } @@ -52,7 +42,7 @@ public function testFile() { $key = 'formPutFile'; $token = $this->auth->uploadToken($this->bucketName, $key); - list($ret, $error) = FormUploader::putFile($token, $key, __file__, $this->cfg, null, 'text/plain', null, false); + list($ret, $error) = FormUploader::putFile($token, $key, __file__, $this->cfg, null, 'text/plain', null); $this->assertNull($error); $this->assertNotNull($ret['hash']); } @@ -62,7 +52,7 @@ public function testFile2() $key = 'formPutFile'; $token = $this->auth->uploadToken($this->bucketName, $key); $upManager = new UploadManager(); - list($ret, $error) = $upManager->putFile($token, $key, __file__, null, 'text/plain', null, false); + list($ret, $error) = $upManager->putFile($token, $key, __file__, null, 'text/plain', null); $this->assertNull($error); $this->assertNotNull($ret['hash']); } diff --git a/tests/Qiniu/Tests/HttpTest.php b/tests/Qiniu/Tests/HttpTest.php old mode 100644 new mode 100755 index 4e4f157d..e2ab5fc6 --- a/tests/Qiniu/Tests/HttpTest.php +++ b/tests/Qiniu/Tests/HttpTest.php @@ -2,9 +2,8 @@ namespace Qiniu\Tests; use Qiniu\Http\Client; -use PHPUnit\Framework\TestCase; -class HttpTest extends TestCase +class HttpTest extends \PHPUnit_Framework_TestCase { public function testGet() { diff --git a/tests/Qiniu/Tests/ImageUrlBuilderTest.php b/tests/Qiniu/Tests/ImageUrlBuilderTest.php old mode 100644 new mode 100755 index 486323cb..fca87b6f --- a/tests/Qiniu/Tests/ImageUrlBuilderTest.php +++ b/tests/Qiniu/Tests/ImageUrlBuilderTest.php @@ -2,8 +2,6 @@ namespace Qiniu\Tests; -use PHPUnit\Framework\TestCase; - /** * imageprocess test * @@ -11,7 +9,7 @@ * @subpackage test * @author Sherlock Ren */ -class ImageUrlBuilderTest extends TestCase +class ImageUrlBuilderTest extends \PHPUnit_Framework_TestCase { /** * 缩略图测试 diff --git a/tests/Qiniu/Tests/PfopTest.php b/tests/Qiniu/Tests/PfopTest.php old mode 100644 new mode 100755 index adb123b6..d03b3f6e --- a/tests/Qiniu/Tests/PfopTest.php +++ b/tests/Qiniu/Tests/PfopTest.php @@ -3,9 +3,8 @@ use Qiniu\Processing\Operation; use Qiniu\Processing\PersistentFop; -use PHPUnit\Framework\TestCase; -class PfopTest extends TestCase +class PfopTest extends \PHPUnit_Framework_TestCase { public function testPfop() { diff --git a/tests/Qiniu/Tests/ResumeUpTest.php b/tests/Qiniu/Tests/ResumeUpTest.php old mode 100644 new mode 100755 index 32828b97..41e6ea8a --- a/tests/Qiniu/Tests/ResumeUpTest.php +++ b/tests/Qiniu/Tests/ResumeUpTest.php @@ -5,14 +5,13 @@ use Qiniu\Storage\UploadManager; use Qiniu\Config; use Qiniu\Zone; -use PHPUnit\Framework\TestCase; -class ResumeUpTest extends TestCase +class ResumeUpTest extends \PHPUnit_Framework_TestCase { protected $bucketName; protected $auth; - protected function setUp(): void + protected function setUp() { global $bucketName; $this->bucketName = $bucketName; @@ -36,7 +35,7 @@ public function test4ML() public function test4ML2() { $key = 'resumePutFile4ML'; - $zone = new Zone(array('up.qiniup.com')); + $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); diff --git a/tests/Qiniu/Tests/ZoneTest.php b/tests/Qiniu/Tests/ZoneTest.php old mode 100644 new mode 100755 index 7e06c447..d32875bd --- a/tests/Qiniu/Tests/ZoneTest.php +++ b/tests/Qiniu/Tests/ZoneTest.php @@ -3,9 +3,8 @@ use Qiniu; use Qiniu\Zone; -use PHPUnit\Framework\TestCase; -class ZoneTest extends TestCase +class ZoneTest extends \PHPUnit_Framework_TestCase { protected $zone; protected $zoneHttps; @@ -16,7 +15,7 @@ class ZoneTest extends TestCase protected $bucketNameNA; - protected function setUp(): void + protected function setUp() { global $bucketName; $this->bucketName = $bucketName; diff --git a/tests/bootstrap.php b/tests/bootstrap.php old mode 100644 new mode 100755 index 5abb8c78..c300057c --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -9,8 +9,8 @@ $testAuth = new Auth($accessKey, $secretKey); $bucketName = 'phpsdk'; -$key = '1503385451.png'; -$key2 = '1503385568.png'; +$key = 'php-logo.png'; +$key2 = 'niu.jpg'; $bucketNameBC = 'phpsdk-bc'; $bucketNameNA = 'phpsdk-na'; @@ -21,7 +21,7 @@ //cdn $timestampAntiLeechEncryptKey = getenv('QINIU_TIMESTAMP_ENCRPTKEY'); -$customDomain = "http://phpsdk.support2technical.me"; +$customDomain = "http://phpsdk.peterpy.cn"; $tid = getenv('TRAVIS_JOB_NUMBER'); if (!empty($tid)) {