添加网站文件

This commit is contained in:
2025-12-22 13:59:40 +08:00
commit 117aaf83d1
19468 changed files with 2111999 additions and 0 deletions

View File

@@ -0,0 +1,145 @@
<?php
namespace Alipay\EasySDK\Test\marketing\openlife;
use Alipay\EasySDK\Kernel\Factory;
use Alipay\EasySDK\Marketing\OpenLife\Models\Article;
use Alipay\EasySDK\Marketing\OpenLife\Models\Context;
use Alipay\EasySDK\Marketing\OpenLife\Models\Keyword;
use Alipay\EasySDK\Marketing\OpenLife\Models\Template;
use Alipay\EasySDK\Test\TestAccount;
use PHPUnit\Framework\TestCase;
class ClientTest extends TestCase
{
public function __construct($name = null, array $data = [], $dataName = '')
{
parent::__construct($name, $data, $dataName);
$account = new TestAccount();
Factory::setOptions($account->getTestCertAccount());
}
public function testCreateImageTextContent()
{
$result = Factory::marketing()->openLife()->createImageTextContent("标题",
"http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
"示例", "T", "activity", "满100减10",
"关键,热度", "13434343432,xxx@163.com");
$this->assertEquals('10000', $result->code);
$this->assertEquals('Success', $result->msg);
}
public function testModifyImageTextContent()
{
$result = Factory::marketing()->openLife()->modifyImageTextContent(
"20190510645210035577f788-d6cd-4020-9dba-1a195edb7342", "新标题",
"http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
"新示例", "T", "activity", "满100减20",
"关键,热度", "13434343432,xxx@163.com");
if ($result->code == '10000') {
$this->assertEquals('10000', $result->code);
$this->assertEquals('Success', $result->msg);
} else {
$this->assertEquals('40004', $result->code);
$this->assertEquals('Business Failed', $result->msg);
$this->assertEquals('PUB.MSG_BATCH_SD_OVER', $result->subCode);
$this->assertEquals('批量发送消息频率超限', $result->subMsg);
}
}
public function testSendText()
{
$result = Factory::marketing()->openLife()->sendText("测试");
if ($result->code == '10000') {
$this->assertEquals('10000', $result->code);
$this->assertEquals('Success', $result->msg);
} else {
$this->assertEquals('40004', $result->code);
$this->assertEquals('Business Failed', $result->msg);
$this->assertEquals('PUB.MSG_BATCH_SD_OVER', $result->subCode);
$this->assertEquals('批量发送消息频率超限', $result->subMsg);
}
}
public function testSendImageText()
{
$article = new Article();
$article->actionName = '测试';
$article->desc = '测试';
$article->title = '测试';
$article->imageUrl = 'http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED';
$article->url = 'https://docs.open.alipay.com/api_6/alipay.open.public.message.total.send';
$result = Factory::marketing()->openLife()->sendImageText((array)$article);
if ($result->code == '10000') {
$this->assertEquals('10000', $result->code);
$this->assertEquals('Success', $result->msg);
} else {
$this->assertEquals('40004', $result->code);
$this->assertEquals('Business Failed', $result->msg);
$this->assertEquals('PUB.MSG_BATCH_SD_OVER', $result->subCode);
$this->assertEquals('批量发送消息频率超限', $result->subMsg);
}
}
public function testSendSingleMessage()
{
$keyword = new Keyword();
$keyword->color = "#85be53";
$keyword->value = "HU7142";
$context = new Context();
$context->headColor = "#85be53";
$context->url = "https://docs.open.alipay.com/api_6/alipay.open.public.message.single.send";
$context->actionName = "查看详情";
$context->keyword1 = $keyword;
$context->keyword2 = $keyword;
$context->first = $keyword;
$context->remark = $keyword;
$template = new Template();
$template->templateId = "e44cd3e52ffa46b1a50afc145f55d1ea";
$template->context = $context;
$result = Factory::marketing()->openLife()->sendSingleMessage("2088002656718920", $template);
$this->assertEquals('10000', $result->code);
$this->assertEquals('Success', $result->msg);
}
public function testRecallMessage()
{
$result = Factory::marketing()->openLife()->recallMessage("201905106452100327f456f6-8dd2-4a06-8b0e-ec8a3a85c46a");
$this->assertEquals('10000', $result->code);
$this->assertEquals('Success', $result->msg);
}
public function testSetIndustry()
{
$result = Factory::marketing()->openLife()->setIndustry(
"10001/20102", "IT科技/IT软件与服务",
"10001/20102", "IT科技/IT软件与服务");
if ($result->code == '10000') {
$this->assertEquals('10000', $result->code);
$this->assertEquals('Success', $result->msg);
} else {
$this->assertEquals('40004', $result->code);
$this->assertEquals('Business Failed', $result->msg);
$this->assertEquals('3002', $result->subCode);
$this->assertEquals('模板消息行业一月只能修改一次', $result->subMsg);
}
}
public function testGetIndustry()
{
$result = Factory::marketing()->openLife()->getIndustry();
$this->assertEquals('10000', $result->code);
$this->assertEquals('Success', $result->msg);
$this->assertEquals('IT科技/IT软件与服务', $result->primaryCategory);
$this->assertEquals('IT科技/IT软件与服务', $result->secondaryCategory);
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace Alipay\EasySDK\Test\marketing\pass;
use Alipay\EasySDK\Kernel\Factory;
use Alipay\EasySDK\Test\TestAccount;
use PHPUnit\Framework\TestCase;
class ClientTest extends TestCase
{
public function __construct($name = null, array $data = [], $dataName = '')
{
parent::__construct($name, $data, $dataName);
$account = new TestAccount();
Factory::setOptions($account->getTestAccount());
}
public function testCreateTemplate()
{
$result = Factory::marketing()->pass()->createTemplate("1234567890", $this->getTplContent());
$this->assertEquals('10000', $result->code);
$this->assertEquals('Success', $result->msg);
}
public function testUpdateTemplate()
{
$result = Factory::marketing()->pass()->updateTemplate("2020012014534017917956080", $this->getTplContent());
$this->assertEquals('10000', $result->code);
$this->assertEquals('Success', $result->msg);
}
public function testAddInstance()
{
$result = Factory::marketing()->pass()->addInstance("2020012014534017917956080", "{}",
"1", "{\"partner_id\":\"2088102114633762\",\"out_trade_no\":\"1234567\"}");
$this->assertEquals('40004', $result->code);
$this->assertEquals('Business Failed', $result->msg);
$this->assertEquals('KP.AE_ALIPASS_APPID_NOSUPPORT', $result->subCode);
$this->assertEquals('该AppId不支持', $result->subMsg);
}
public function testUpdateInstance()
{
$result = Factory::marketing()->pass()->updateInstance("209919213",
"2088918273", "{}", "USED", "8612231273", "wave");
$this->assertEquals('40004', $result->code);
$this->assertEquals('Business Failed', $result->msg);
$this->assertEquals('KP.AE_ALIPASS_NOTEXIST', $result->subCode);
$this->assertEquals('卡券不存在', $result->subMsg);
}
private function getTplContent()
{
return '{"logo": "http://img01.taobaocdn.com/top/i1/LB1NDJuQpXXXXbYXFXXXXXXXXXX","strip": null,"icon": null,"content": {
"evoucherInfo": {
"goodsId": "",
"title": "test",
"type": "boardingPass",
"product": "air",
"startDate": "2020-01-20 13:45:56",
"endDate": "2020-01-25 13:45:56",
"operation": [{
"message": {
"img": "http://img01.taobaocdn.com/top/i1/LB1NDJuQpXXXXbYXFXXXXXXXXXX",
"target": ""
},
"format": "img",
"messageEncoding": "utf-8",
"altText": ""
}],
"einfo": {
"logoText": "test",
"headFields": [{"key": "test","label": "测试","value": "","type": "text"}],
"primaryFields": [{"key": "from","label": "测试","value": "","type": "text"},{"key": "to","label": "测试","value": "","type": "text"}],
"secondaryFields": [{"key": "fltNo","label": "航班号","value": "CA123","type": "text"}],
"auxiliaryFields": [{"key": "test","label": "测试","value": "","type": "text"}],
"backFields": []
},
"locations": []
},
"merchant": {"mname": "君泓","mtel": "","minfo": ""},
"platform": {
"channelID": "2088201564809153",
"webServiceUrl": "https://alipass.alipay.com/builder/syncRecord.htm?tempId=2020012013442621326446216"
},
"style": {"backgroundColor": "RGB(26,150,219)"},
"fileInfo": {
"formatVersion": "2",
"canShare": true,
"canBuy": false,
"canPresent": true,
"serialNumber": "2020012013520759738677158",
"supportTaxi": "true",
"taxiSchemaUrl": ""
},
"appInfo": {"app": {"android_appid": "","ios_appid": "","android_launch": "","ios_launch": "","android_download": "","ios_download": ""},"label": "测试","message": ""},
"source": "alipassprod",
"alipayVerify": ["qrcode"]}}';
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Alipay\EasySDK\Test\marketing\templatemessage;
use Alipay\EasySDK\Kernel\Factory;
use Alipay\EasySDK\Test\TestAccount;
use PHPUnit\Framework\TestCase;
class ClientTest extends TestCase
{
public function testSend(){
$account = new TestAccount();
Factory::setOptions($account->getTestAccount());
$result = Factory::marketing()->templateMessage()->send("2088102122458832",
"2017010100000000580012345678",
"MDI4YzIxMDE2M2I5YTQzYjUxNWE4MjA4NmU1MTIyYmM=",
"page/component/index",
"{\"keyword1\": {\"value\" : \"12:00\"},\"keyword2\": {\"value\" : \"20180808\"},\"keyword3\": {\"value\" : \"支付宝\"}}");
$this->assertEquals('40004',$result->code);
$this->assertEquals('Business Failed',$result->msg);
$this->assertEquals('USER_TEMPLATE_ILLEGAL',$result->subCode);
$this->assertEquals('模板非法',$result->subMsg);
}
}