Skip to content

Commit

Permalink
Merge pull request #308 from qiniu/develop
Browse files Browse the repository at this point in the history
delete checkCrc
  • Loading branch information
rwifeng authored Jul 9, 2019
2 parents 464f3eb + a6f70d6 commit afe7d87
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 92 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ php:
- 5.5
- 5.6
- 7.0
- 7.2

before_script:
- export QINIU_TEST_ENV="travis"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~8.0",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.3"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/Qiniu/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 分块上传块大小,该参数为接口规格,不能修改

Expand Down
3 changes: 1 addition & 2 deletions src/Qiniu/Storage/FormUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public static function put(
$config,
$params,
$mime,
$fname,
$checkCrc
$fname
) {
$fields = array('token' => $upToken);
if ($key === null) {
Expand Down
9 changes: 3 additions & 6 deletions src/Qiniu/Storage/UploadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public function put(
$data,
$params = null,
$mime = 'application/octet-stream',
$fname = null,
$checkCrc = false
$fname = null
) {

$params = self::trimParams($params);
Expand All @@ -58,8 +57,7 @@ public function put(
$this->config,
$params,
$mime,
$fname,
$checkCrc
$fname
);
}

Expand Down Expand Up @@ -110,8 +108,7 @@ public function putFile(
$this->config,
$params,
$mime,
basename($filePath),
$checkCrc
basename($filePath)
);
}

Expand Down
23 changes: 10 additions & 13 deletions tests/Qiniu/Tests/AuthTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -43,18 +39,15 @@ 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()
{
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']);
}
Expand All @@ -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()
{
}
}
}
3 changes: 1 addition & 2 deletions tests/Qiniu/Tests/Base64Test.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
5 changes: 2 additions & 3 deletions tests/Qiniu/Tests/BucketTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
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;
protected $bucketName;
protected $key;
protected $key2;

protected function setUp(): void
protected function setUp()
{
global $bucketName;
global $key;
Expand Down
16 changes: 3 additions & 13 deletions tests/Qiniu/Tests/CdnManagerTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
3 changes: 1 addition & 2 deletions tests/Qiniu/Tests/Crc32Test.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
7 changes: 3 additions & 4 deletions tests/Qiniu/Tests/DownloadTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions tests/Qiniu/Tests/EtagTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
17 changes: 8 additions & 9 deletions tests/Qiniu/Tests/FopTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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');
}
}
22 changes: 6 additions & 16 deletions tests/Qiniu/Tests/FormUpTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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']);
}
Expand All @@ -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']);
}
Expand All @@ -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']);
}
Expand All @@ -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']);
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Qiniu/Tests/HttpTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
4 changes: 1 addition & 3 deletions tests/Qiniu/Tests/ImageUrlBuilderTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

namespace Qiniu\Tests;

use PHPUnit\Framework\TestCase;

/**
* imageprocess test
*
* @package Qiniu
* @subpackage test
* @author Sherlock Ren <[email protected]>
*/
class ImageUrlBuilderTest extends TestCase
class ImageUrlBuilderTest extends \PHPUnit_Framework_TestCase
{
/**
* 缩略图测试
Expand Down
3 changes: 1 addition & 2 deletions tests/Qiniu/Tests/PfopTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Loading

0 comments on commit afe7d87

Please sign in to comment.