Files
huangjingfen/pro_v3.5.1_副本/vendor/qcloud/cos-sdk-v5/tests/CosClientObjectTest.php
apple 434aa8c69d feat(fsgx): 完成全部24项开发任务 Phase1-7
Phase1 后端核心:
- 新增 fsgx_v1.sql 迁移脚本(is_queue_goods/frozen_points/available_points/no_assess)
- SystemConfigServices 返佣设置扩展(周期人数/分档比例/范围/时机)
- StoreOrderCreateServices 周期循环佣金计算
- StoreOrderTakeServices 佣金发放后同步冻结积分
- StoreProductServices/StoreProduct 保存 is_queue_goods

Phase2 后端接口:
- GET /api/hjf/brokerage/progress 佣金周期进度
- GET /api/hjf/assets/overview 资产总览
- HjfPointsServices 每日 frozen_points 0.4‰ 释放定时任务
- PUT /adminapi/hjf/member/{uid}/no_assess 不考核接口
- GET /adminapi/hjf/points/release_log 积分日志接口

Phase3 前端清理:
- hjfCustom.js 路由精简(仅保留 points/log)
- hjfQueue.js/hjfMember.js API 清理/重定向至 CRMEB 原生接口
- pages.json 公排→推荐佣金/佣金记录/佣金规则

Phase4-5 前端改造:
- queue/status.vue 推荐佣金进度页整体重写
- 商品详情/订单确认/支付结果页文案与逻辑改造
- 个人中心/资产页/引导页/规则页文案改造
- HjfQueueProgress/HjfRefundNotice/HjfAssetCard 组件改造
- 推广中心嵌入佣金进度摘要
- hjfMockData.js 全量更新(公排字段→佣金字段)

Phase6 Admin 增强:
- 用户列表新增 frozen_points/available_points 列及不考核操作按钮
- hjfPoints.js USE_MOCK=false 对接真实积分日志接口

Phase7 配置文档:
- docs/fsgx-phase7-config-checklist.md 后台配置与全链路验收清单

Made-with: Cursor
2026-03-23 22:32:19 +08:00

970 lines
30 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Qcloud\Cos\Tests;
use Qcloud\Cos\Exception\ServiceResponseException;
class CosClientObjectTest extends TestCosClientBase {
private $key;
private $appendKey;
private $aclKey;
private $uin;
/**********************************
* TestObject
**********************************/
/*
* put object, 从本地上传文件
* 200
*/
public function testPutObjectLocalObject() {
try {
$local_test_key = Common::LOCAL_TEST_FILE;
$body = Common::generateFile();
$md5 = base64_encode(md5($body, true));
$this->cosClient->putObject(['Bucket' => $this->bucket,
'Key' => $this->key,
'Body' => fopen($local_test_key, "rb")]);
$rt = $this->cosClient->getObject(['Bucket'=>$this->bucket, 'Key'=>$this->key]);
$download_md5 = base64_encode(md5($rt['Body'], true));
$this->assertEquals($md5, $download_md5);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* upload, 从本地上传
* 200
*/
public function testUploadLocalObject() {
try {
$local_test_key = Common::LOCAL_TEST_FILE;
$body = Common::generateFile();
$md5 = base64_encode(md5($body, true));
$this->cosClient->upload($bucket=$this->bucket,
$key=$this->key,
$body=fopen($local_test_key, "rb"),
$options=['PartSize'=>1024 * 1024 + 1]);
$rt = $this->cosClient->getObject(['Bucket'=>$this->bucket, 'Key'=>$key]);
$download_md5 = base64_encode(md5($rt['Body'], true));
$this->assertEquals($md5, $download_md5);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object,请求头部携带服务端加密参数
* 200
*/
public function testPutObjectEncryption()
{
try {
$this->cosClient->putObject(
array(
'Bucket' => $this->bucket,
'Key' => '11//32//43',
'Body' => 'Hello World!',
'ServerSideEncryption' => 'AES256'
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 上传小文件
* 200
*/
public function testUploadSmallObject() {
try {
$this->cosClient->upload($this->bucket, $this->key, 'Hello World');
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 上传空文件
* 200
*/
public function testPutObjectEmpty() {
try {
$this->cosClient->upload($this->bucket, $this->key, '');
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 上传已存在的文件
* 200
*/
public function testPutObjectExisted() {
try {
$this->cosClient->upload($this->bucket, $this->key, '1234124');
Common::waitSync();
$this->cosClient->upload($this->bucket, $this->key, '请二位qwe');
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object请求头部携带自定义头部x-cos-meta-
* 200
*/
public function testPutObjectMeta() {
try {
$meta = array(
'test' => str_repeat('a', 1 * 1024),
'test-meta' => '中文qwe-23ds-ad-xcz.asd.*qweqw'
);
$this->cosClient->putObject(array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'Body' => '1234124',
'Metadata' => $meta
));
$rt = $this->cosClient->headObject(array('Bucket'=>$this->bucket, 'Key'=>$this->key));
$this->assertEquals($rt['Metadata'], $meta);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* upload large object请求头部携带自定义头部x-cos-meta-
* 200
*/
public function testUploadLargeObjectMeta() {
try {
$meta = array(
'test' => str_repeat('a', 1 * 1024),
'test-meta' => 'qwe-23ds-ad-xcz.asd.*qweqw'
);
$body = Common::generateRandomString(2*1024*1024+1023);
$this->cosClient->upload($this->bucket, $this->key, $body, array('PartSize'=>1024 * 1024 + 1, 'Metadata'=>$meta));
Common::waitSync();
$rt = $this->cosClient->headObject(['Bucket'=>$this->bucket, 'Key'=>$this->key]);
$this->assertEquals($rt['Metadata'], $meta);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object请求头部携带自定义头部x-cos-meta-
* KeyTooLong
* 400
*/
public function testPutObjectMeta2K() {
try {
$this->cosClient->putObject(array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'Body' => '1234124',
'Metadata' => array(
'lew' => str_repeat('a', 3 * 1024),
)));
$this->assertTrue(False);
} catch (ServiceResponseException $e) {
$this->assertEquals(
[400, 'KeyTooLong'],
[$e->getStatusCode(), $e->getExceptionCode()]
);
}
}
/*
* 上传复杂文件名的文件
* 200
*/
public function testUploadComplexObject() {
try {
$key = '→↓←→↖↗↙↘! \"#$%&\'()*+,-./0123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
$this->cosClient->upload($this->bucket, $key, 'Hello World');
$this->cosClient->headObject(array(
'Bucket' => $this->bucket,
'Key' => $key
));
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 上传大文件
* 200
*/
public function testUploadLargeObject() {
try {
$body = Common::generateRandomString(2*1024*1024+1023);
$md5 = base64_encode(md5($body, true));
$this->cosClient->upload($bucket=$this->bucket,
$key=$this->key,
$body=$body,
$options=['PartSize'=>1024 * 1024 + 1]);
$rt = $this->cosClient->getObject(['Bucket'=>$this->bucket, 'Key'=>$key]);
$download_md5 = base64_encode(md5($rt['Body'], true));
$this->assertEquals($md5, $download_md5);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 断点重传
* 200
*/
public function testResumeUpload() {
try {
$body = Common::generateRandomString(3*1024*1024+1023);
$partSize = 1024 * 1024 + 1;
$md5 = base64_encode(md5($body, true));
$rt = $this->cosClient->CreateMultipartUpload(['Bucket' => $this->bucket,
'Key' => $this->key]);
$uploadId = $rt['UploadId'];
$this->cosClient->uploadPart(['Bucket' => $this->bucket,
'Key' => $this->key,
'Body' => substr($body, 0, $partSize),
'UploadId' => $uploadId,
'PartNumber' => 1]);
$rt = $this->cosClient->ListParts(['Bucket' => $this->bucket,
'Key' => $this->key,
'UploadId' => $uploadId]);
$this->assertEquals(1, count($rt['Parts']));
$this->cosClient->resumeUpload($bucket=$this->bucket,
$this->key,
$body,
$uploadId,
array('PartSize'=>$partSize));
$rt = $this->cosClient->getObject(['Bucket'=>$this->bucket, 'Key'=>$this->key]);
$download_md5 = base64_encode(md5($rt['Body'], true));
$this->assertEquals($md5, $download_md5);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 下载文件
* 200
*/
public function testGetObject() {
try {
$this->cosClient->upload($this->bucket, $this->key, 'Hello World');
$this->cosClient->getObject(array(
'Bucket' => $this->bucket,
'Key' => $this->key,));
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* range下载大文件
* 200
*/
public function testDownloadLargeObject() {
try {
$local_path = "test_tmp_file";
$body = Common::generateRandomString(2*1024*1024+1023);
$md5 = base64_encode(md5($body, true));
$this->cosClient->upload($this->bucket,
$this->key,
$body,
array('PartSize'=>1024 * 1024 + 1));
$this->cosClient->download($this->bucket,
$this->key,
$local_path,
array('PartSize'=>1024 * 1024 + 1));
$body = file_get_contents($local_path);
$download_md5 = base64_encode(md5($body, true));
$this->assertEquals($md5, $download_md5);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* get objectobject名称包含特殊字符
* 200
*/
public function testGetObjectSpecialName() {
try {
$this->cosClient->upload($this->bucket, '你好<>!@#^%^&*&(&^!@#@!.txt', 'Hello World');
$this->cosClient->getObject(array(
'Bucket' => $this->bucket,
'Key' => '你好<>!@#^%^&*&(&^!@#@!.txt',));
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* get object请求头部带if-match参数值为true
* 200
*/
public function testGetObjectIfMatchTrue() {
try {
$this->cosClient->upload($this->bucket, $this->key, 'Hello World');
$this->cosClient->getObject(array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'IfMatch' => '"b10a8db164e0754105b7a99be72e3fe5"'));
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* get object请求头部带if-match参数值为false
* PreconditionFailed
* 412
*/
public function testGetObjectIfMatchFalse() {
try {
$this->cosClient->upload($this->bucket, $this->key, 'Hello World');
$this->cosClient->getObject(array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'IfMatch' => '""'));
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertEquals(
[412, 'PreconditionFailed'],
[$e->getStatusCode(), $e->getExceptionCode()]
);
}
}
/*
* get object请求头部带if-none-match参数值为true
* 200
*/
public function testGetObjectIfNoneMatchTrue() {
try {
$this->cosClient->upload($this->bucket, $this->key, 'Hello World');
$rt = $this->cosClient->getObject(array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'IfNoneMatch' => '"b10a8db164e0754105b7a99be72e3fe5"'));
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* get object请求头部带if-none-match参数值为false
* PreconditionFailed
* 412
*/
public function testGetObjectIfNoneMatchFalse() {
try {
$this->cosClient->upload($this->bucket, $this->key, 'Hello World');
$this->cosClient->getObject(array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'IfNoneMatch' => '""'));
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 获取文件url
* 200
*/
public function testGetObjectUrl() {
try{
$this->cosClient->getObjectUrl($this->bucket, $this->key, '+10 minutes');
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 获取文件基本url
* 200
*/
public function testGetObjectUrlWithoutSign() {
try{
$result = $this->cosClient->getObjectUrlWithoutSign($this->bucket, $this->key);
$tmpUrl = 'https://' . $this->bucket . '.cos.' . Common::getRegion() . '.myqcloud.com/' . $this->key;
$this->assertEquals($result, $tmpUrl);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 复制小文件
* 200
*/
public function testCopySmallObject() {
try{
$this->cosClient->upload($this->bucket, $this->key, 'Hello World');
$this->cosClient->copy($bucket=$this->bucket,
$test_key='hello.txt',
$copySource = ['Bucket'=>$this->bucket,
'Region'=>Common::getRegion(),
'Key'=>$this->key]);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 复制大文件
* 200
*/
public function testCopyLargeObject() {
try{
$src_key = '你好.txt';
$dst_key = 'hi.txt';
$body = Common::generateRandomString(2*1024*1024+333);
$md5 = base64_encode(md5($body, true));
$this->cosClient->upload($bucket=$this->bucket,
$key=$src_key,
$body=$body,
$options=['PartSize'=>1024 * 1024 + 1]);
$this->cosClient->copy($bucket=$this->bucket,
$key=$dst_key,
$copySource = ['Bucket'=>$this->bucket,
'Region'=>Common::getRegion(),
'Key'=>$src_key],
$options=['PartSize'=>1024 * 1024 + 1]);
$rt = $this->cosClient->getObject(['Bucket'=>$this->bucket, 'Key'=>$dst_key]);
$download_md5 = base64_encode(md5($rt['Body'], true));
$this->assertEquals($md5, $download_md5);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 设置objectacl
* 200
*/
public function testPutObjectACL() {
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'Grants' => array(
array(
'Grantee' => array(
'DisplayName' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
'ID' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
'Type' => 'CanonicalUser',
),
'Permission' => 'FULL_CONTROL',
),
// ... repeated
),
'Owner' => array(
'DisplayName' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
'ID' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
)
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 获取objectacl
* 200
*/
public function testGetObjectACL()
{
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'Grants' => array(
array(
'Grantee' => array(
'DisplayName' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
'ID' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
'Type' => 'CanonicalUser',
),
'Permission' => 'FULL_CONTROL',
),
),
'Owner' => array(
'DisplayName' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
'ID' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
)
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object acl设置object公共权限为private
* 200
*/
public function testPutObjectAclPrivate()
{
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'ACL'=>'private'
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object acl设置object公共权限为public-read
* 200
*/
public function testPutObjectAclPublicRead()
{
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'ACL'=>'public-read'
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object acl公共权限非法
* InvalidArgument
* 400
*/
public function testPutObjectAclInvalid()
{
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'ACL'=>'public'
)
);
$this->assertTrue(False);
} catch (ServiceResponseException $e) {
$this->assertTrue($e->getExceptionCode() === 'InvalidArgument' && $e->getStatusCode() === 400);
}
}
/*
* put object acl设置object账号权限为grant-read
* 200
*/
public function testPutObjectAclReadToUser()
{
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'GrantRead' => 'id="qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin . '"'
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object acl设置object账号权限为grant-full-control
* 200
*/
public function testPutObjectAclFullToUser()
{
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'GrantFullControl' => 'id="qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin . '"'
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object acl设置object账号权限同时授权给多个账户
* 200
*/
public function testPutObjectAclToUsers()
{
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'GrantFullControl' => 'id="qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin . '",id="qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin . '",id="qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin . '"'
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object acl设置object账号权限授权给子账号
* 200
*/
public function testPutObjectAclToSubuser()
{
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'GrantFullControl' => 'id="qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin . '"'
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object acl设置object账号权限grant值非法
* InvalidArgument
* 400
*/
public function testPutObjectAclInvalidGrant()
{
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'GrantFullControl' => 'id="qcs::camuin/321023:uin/100018617869"'
)
);
$this->assertTrue(False);
} catch (ServiceResponseException $e) {
$this->assertTrue($e->getExceptionCode() === 'InvalidArgument' && $e->getStatusCode() === 400);
}
}
/*
* put object acl设置object账号权限通过body方式授权
* 200
*/
public function testPutObjectAclByBody()
{
try {
$this->cosClient->PutObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'Grants' => array(
array(
'Grantee' => array(
'DisplayName' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
'ID' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
'Type' => 'CanonicalUser',
),
'Permission' => 'FULL_CONTROL',
),
// ... repeated
),
'Owner' => array(
'DisplayName' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
'ID' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
)
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* put object acl设置object账号权限通过body方式授权给anyone
* 200
*/
public function testPutObjectAclByBodyToAnyone()
{
try {
$this->cosClient->putObjectAcl(
array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'Grants' => array(
array(
'Grantee' => array(
'DisplayName' => 'qcs::cam::anyone:anyone',
'ID' => 'qcs::cam::anyone:anyone',
'Type' => 'CanonicalUser',
),
'Permission' => 'FULL_CONTROL',
),
// ... repeated
),
'Owner' => array(
'DisplayName' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
'ID' => 'qcs::cam::uin/' . $this->uin . ':uin/' . $this->uin,
)
)
);
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* get object taggingobject不存在
* NoSuchKey
* 404
*/
public function testPutObjectTaggingObjectNonExisted()
{
$tagSet = Common::getTagSet();
try {
$this->cosClient->putObjectTagging(
array(
'Bucket' => $this->bucket,
'Key' => $this->key . 'tmp',
'TagSet' => $tagSet
)
);
$this->assertTrue(false);
} catch (ServiceResponseException $e) {
$this->assertTrue($e->getExceptionCode() === 'NoSuchKey' && $e->getStatusCode() === 404);
}
}
/*
* append object相关测试
*/
public function testAppendObject()
{
$local_test_key = Common::LOCAL_TEST_FILE;
Common::generateFile();
$content_array = array('hello cos', 'hi cos');
/**
* 追加上传字符流
*/
try {
$position = $this->cosClient->appendObject(array(
'Bucket' => $this->bucket,
'Key' => $this->appendKey,
'Position' => 0,
'Body' => $content_array[0]))['Position'];
$this->assertEquals($position, strlen($content_array[0]));
$position = $this->cosClient->appendObject(array(
'Bucket' => $this->bucket,
'Key' => $this->appendKey,
'Position' => (integer)$position,
'Body' => $content_array[1]))['Position'];
$this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]));
} catch (ServiceResponseException $e) {
$this->assertFalse(true);
}
/**
* 检查追加上传字符流与下载对象内容是否一致
*/
try {
$content = $this->cosClient->getObject(array('Bucket'=>$this->bucket, 'Key'=>$this->appendKey));
$this->assertEquals($content['Body'], implode($content_array));
} catch (ServiceResponseException $e) {
$this->assertFalse(true);
}
/**
* 删除测试对象
*/
try {
$this->cosClient->deleteObject(array('Bucket'=>$this->bucket, 'Key'=>$this->appendKey));
} catch (ServiceResponseException $e) {
$this->assertFalse(true);
}
/**
* 追加本地文件
*/
try {
$position = $this->cosClient->appendObject(array(
'Bucket' => $this->bucket,
'Key' => $this->appendKey,
'Position' => 0,
'Body' => fopen($local_test_key, 'rb')
))['Position'];
$this->assertEquals($position, filesize($local_test_key));
} catch (ServiceResponseException $e) {
$this->assertFalse(true);
}
/**
* 检查追加上传文件与下载对象内容是否一致
*/
try {
$md5 = base64_encode(md5(file_get_contents($local_test_key), true));
$rt = $this->cosClient->getObject(array('Bucket'=>$this->bucket, 'Key'=>$this->appendKey));
$download_md5 = base64_encode(md5($rt['Body'], true));
$this->assertEquals($md5, $download_md5);
} catch (ServiceResponseException $e) {
$this->assertFalse(true);
}
}
/*
* 正常put对象标签
* 200
*/
public function testPutObjectTagging()
{
$tagSet = Common::getTagSet();
try {
$this->cosClient->putObjectTagging(array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'TagSet' => $tagSet
));
$rt = $this->cosClient->getObjectTagging(array(
'Bucket' => $this->bucket,
'Key' => $this->key
));
$this->assertEquals($rt['TagSet'], $tagSet);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 正常get对象标签
* 200
*/
public function testGetObjectTagging()
{
$tagSet = Common::getTagSet();
try {
$this->cosClient->putObjectTagging(array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'TagSet' => $tagSet
));
$this->cosClient->getObjectTagging(array(
'Bucket' => $this->bucket,
'Key' => $this->key
));
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
/*
* 正常delete对象标签
* 200
*/
public function testDeleteObjectTagging()
{
$tagSet = Common::getTagSet();
try {
$this->cosClient->putObjectTagging(array(
'Bucket' => $this->bucket,
'Key' => $this->key,
'TagSet' => $tagSet
));
Common::waitSync();
$this->cosClient->deleteObjectTagging(array(
'Bucket' => $this->bucket,
'Key' => $this->key
));
$this->assertTrue(True);
} catch (ServiceResponseException $e) {
$this->assertFalse(True);
}
}
protected function setUp(): void
{
parent::setUp();
$this->key = Common::FILE_NAME;
$this->uin = Common::getUin();
$this->appendKey = $this->key.'append';
$this->cosClient->putObject(array('Bucket' => $this->bucket,'Key' => $this->key, 'Body' => '123'));
}
protected function tearDown(): void {
parent::tearDown();
}
}