Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete checkCrc #306

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .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 All @@ -21,9 +20,4 @@ script:

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

env:
global:
- secure: "V9BsntXQZwvO9EOD6itzaae2uq+GemzyTUTxMTJx1/jFoUNpCU2O2UAgjA2XSEr5sgci0KWDV4Krbzv3EBB4uplOFLMI3w32256UHbT9E0x3YjhfPJZk68MH1iS1be7X81LDHON7yveavK8987s3qzjeUcbfLSPgccT+cvf7+dc="
- QINIU_ACCESS_KEY=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~8.0",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.3"
},
"autoload": {
"psr-4": {"Qiniu\\": "src/Qiniu"},
"files": ["src/Qiniu/functions.php"]
}
}
}
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
12 changes: 4 additions & 8 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 All @@ -86,8 +84,7 @@ public function putFile(
$key,
$filePath,
$params = null,
$mime = 'application/octet-stream',
$checkCrc = false
$mime = 'application/octet-stream'
) {

$file = fopen($filePath, 'rb');
Expand All @@ -110,8 +107,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
5 changes: 2 additions & 3 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 Down
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
Loading