This repository has been archived by the owner on Oct 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
TestCase.php
234 lines (185 loc) · 11.8 KB
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
use CHWechatShop\Model\CHWechatShopDelivery;
use CHWechatShop\Model\CHWechatShopExpressFee;
use CHWechatShop\Model\CHWechatShopExpressTemplate;
use CHWechatShop\Model\CHWechatShopGroup;
use CHWechatShop\Model\CHWechatShopGroupModify;
use CHWechatShop\Model\CHWechatShopProduct;
use CHWechatShop\Model\CHWechatShopShelf;
use CHWechatShop\Model\CHWechatShopShelfData1;
use CHWechatShop\Model\CHWechatShopShelfData2;
use CHWechatShop\Model\CHWechatShopShelfData3;
use CHWechatShop\Model\CHWechatShopShelfData4;
use CHWechatShop\CHWechatShop;
use CHWechatShop\CHWechatShopConst;
use PHPUnit_Framework_TestCase;
class TestCase extends PHPUnit_Framework_TestCase {
public static function register() {
spl_autoload_register("TestCase::loadClass");
}
public static function loadClass($class) {
$class = str_replace('\\', '/', $class);
$class = "./".$class.".php";
require_once $class;
}
public function testShop(){
self::register();
$result = array();
// // 上传图片
// $result['uploadImage'] = array('params' => array('imagePath' => "image.png"),
// 'result' => CHWechatShop::uploadImage("image.png", "image.png"));
// $image = $result['uploadImage']['result']['image_url'];
// // 创建商品
// $product = new CHWechatShopProduct();
// $product->setName('测试商品')
// ->setCategoryId('537074298')
// ->setMainImage($image)
// ->addImage($image)
// ->addDetailText('添加描述')
// ->addDetailText(date('Y-m-d h:m:s'))
// ->setPostFree(CHWechatShopConst::NOT_POST_FREE)
// ->addCustomExpress(CHWechatShopConst::DELIVERY_TYPE_ID_EMS, 200)
// ->addSku(null, 2000, $image, 30);
// $result['productCreate'] = array('params' => array('product' => $product),
// 'result' => CHWechatShop::productCreate($product));
// // 获取分类
// $result['getCategories'] = array('params' => array('categoryId' => 538115192),
// 'result' => CHWechatShop::getCategories(538115192));
// // 获取分类SKU
// $result['getCategorySKU'] = array('params' => array('categoryId' => 537115215),
// 'result' => CHWechatShop::getCategorySKU(537115215));
// // 获取分类属性
// $result['getProductByStatus'] = array('params' => array('categoryId' => 537115215),
// 'result' => CHWechatShop::getCategoryProperty(537115215));
// if ($result['productCreate']['result']['errcode'] == 0) {
// $productId = $result['productCreate']['result']['product_id'];
// // 删除商品
// $result['productRemove'] = array('params' => array('productId' => $productId),
// 'result' => CHWechatShop::productRemove($productId));
// }
// // 增加货架
// $shelf = (new CHWechatShopShelf())->setShelfBanner($image)->setShelfName("测试货架");
// $shelf->addShelfData((new CHWechatShopShelfData1())->setProductCount(4)->setGroupId('416310720'))
// ->addShelfData((new CHWechatShopShelfData2())->addGroup('416488071')->addGroup('416488061')->addGroup('416310720'))
// ->addShelfData((new CHWechatShopShelfData3())->setGroupId('416488071')->setImage($image))
// ->addShelfData((new CHWechatShopShelfData4())->addGroup('416310720', $image)->addGroup('416488071', $image)->addGroup('416488061', $image));
// // 获取指定状态的所有商品
// $result['getProductByStatus'] = array('params' => array('status' => CHWechatShopConst::PRODUCT_SHELVE),
// 'result' => CHWechatShop::getProductByStatus(CHWechatShopConst::PRODUCT_SHELVE));
// // 获取指定状态的所有商品
// $result['getProduct'] = array('params' => array('productId' => 'pXy6ujkx01pfqTaThrSDLd9G0PJ4'),
// 'result' => CHWechatShop::getProduct('pXy6ujkx01pfqTaThrSDLd9G0PJ4'));
// if ($result['getProduct']['result']['errcode'] == 0) {
// $product = new CHWechatShopProduct($result['getProduct']['result']['product_info']);
// $product->removeDetail()->addDetailText('添加描述')->addDetailText(date('Y-m-d h:m:s'));
// // 修改商品
// $result['productModify'] = array('params' => array('product' => $product),
// 'result' => CHWechatShop::productModify($product));
// }
// // 上架
// $result['shelve'] = array('params' => array('productId' => 'pXy6ujkx01pfqTaThrSDLd9G0PJ4', 'status' => CHWechatShopConst::PRODUCT_SHELVE),
// 'result' => CHWechatShop::productStatus('pXy6ujkx01pfqTaThrSDLd9G0PJ4', CHWechatShopConst::PRODUCT_SHELVE));
// // 增加库存
// $result['addStock'] = array('params' => array('productId' => 'pXy6ujkx01pfqTaThrSDLd9G0PJ4', '$quantity' => 1),
// 'result' => CHWechatShop::addStock('pXy6ujkx01pfqTaThrSDLd9G0PJ4', 1));
// // 减少库存
// $result['reduceStock'] = array('params' => array('productId' => 'pXy6ujkx01pfqTaThrSDLd9G0PJ4', '$quantity' => 1),
// 'result' => CHWechatShop::reduceStock('pXy6ujkx01pfqTaThrSDLd9G0PJ4', 1));
// // 增加邮费模板
// $templete = new CHWechatShopExpressTemplate();
// $normalFee = new CHWechatShopExpressFee();
// $customFee = new CHWechatShopExpressFee();
// $normalFee->setFee(1, 100, 1, 200);
// $customFee->setFee(1, 100, 1, 200)->setCity('中国', '广东省', '广州市');
// $templete->setName('新建测试模版')->setAssumer(CHWechatShopConst::BUYER_PAY_DELIVERY_FEE)->addFee(CHWechatShopConst::DELIVERY_TYPE_ID_EXPRESS, $normalFee, array($customFee));
// $result['expressTemplateCreate'] = array('params' => array('templete' => $templete),
// 'result' => CHWechatShop::expressTemplateCreate($templete));
// if ($result['expressTemplateCreate']['result']['errcode'] == 0) {
// $templeteId = $result['expressTemplateCreate']['result']['template_id'];
// // 获取指定ID的邮费模板
// $result['getExpressTemplate'] = array('params' => array('templateId' => $templeteId),
// 'result' => CHWechatShop::getExpressTemplate($templeteId));
// $templete = new CHWechatShopExpressTemplate($result['getExpressTemplate']['result']['template_info']);
// $normalFee = new CHWechatShopExpressFee();
// $customFee = new CHWechatShopExpressFee();
// $normalFee->setFee(2, 1000, 2, 2000);
// $customFee->setFee(2, 1000, 2, 2000)->setCity('中国', '山西省', '太原市');
// $templete->setName('修改测试模版')->removeFees()->setAssumer(CHWechatShopConst::BUYER_PAY_DELIVERY_FEE)->addFee(CHWechatShopConst::DELIVERY_TYPE_ID_EXPRESS, $normalFee, array($customFee));
// // 修改邮费模板
// $result['expressTemplateModify'] = array('params' => array('templateId' => $templeteId, 'template' => $templete),
// 'result' => CHWechatShop::expressTemplateModify($templeteId, $templete));
// // 删除邮费模板
// $result['expressTemplateRemove'] = array('params' => array('templateId' => $templeteId),
// 'result' => CHWechatShop::expressTemplateRemove($templeteId));
// }
// // 增加分组
// $group = new CHWechatShopGroup();
// $group->setGroupName('测试分组')->addProduct('pXy6ujkx01pfqTaThrSDLd9G0PJ4');
// $result['groupCreate'] = array('params' => array('group' => $group),
// 'result' => CHWechatShop::groupCreate($group));
// if ($result['groupCreate']['result']['errcode'] == 0) {
// $groupId = $result['groupCreate']['result']['group_id'];
// sleep(1);
// // 获取分组
// $result['getGroup'] = array('params' => array('groupId' => $groupId),
// 'result' => CHWechatShop::getGroup($groupId));
// // 编辑分组名
// $result['updateGroupName'] = array('params' => array('groupId' => $groupId, 'groupName' => '修改分组名'),
// 'result' => CHWechatShop::updateGroupName($groupId, '修改分组名'));
// $modify = new CHWechatShopGroupModify('pXy6ujkx01pfqTaThrSDLd9G0PJ4', CHWechatShopConst::GROUP_PRODUCT_ADD);
// // 修改分组商品
// $result['updateGroupProduct'] = array('params' => array('groupId' => $groupId, 'groupName' => '修改分组名'),
// 'result' => CHWechatShop::updateGroupProduct($groupId, array($modify)));
// // 编辑分组名
// $result['updateGroupName'] = array('params' => array('groupId' => $groupId, 'groupName' => '修改分组名'),
// 'result' => CHWechatShop::updateGroupName($groupId, '修改分组名'));
// // 删除分组
// $result['groupRemove'] = array('params' => array('groupId' => $groupId),
// 'result' => CHWechatShop::groupRemove($groupId));
// }
// // 获取所有分组
// $result['getAllGroup'] = array('params' => null,
// 'result' => CHWechatShop::getAllGroup());
// $delivery = new CHWechatShopDelivery();
// $delivery->setOrderId('10281205985306658720')->setDeliveryTrackNo('111122223333')->setDeliveryCompany(CHWechatShopConst::EXPRESS_ID_SHUNFENG);
// // 设置订单发货信息
// $result['setDelivery'] = array('params' => array('delivery' => $delivery),
// 'result' => CHWechatShop::setDelivery($delivery));
// // 关闭订单
// $result['orderClose'] = array('params' => array('orderId' => '10281205985306658720'),
// 'result' => CHWechatShop::orderClose('10281205985306658720'));
// // 获取订单
// $result['getOrder'] = array('params' => array('orderId' => '10281205985306658720'),
// 'result' => CHWechatShop::getOrder('10281205985306658720'));
// // 根据订单状态/创建时间获取订单详情
// $result['getOrderByStatus'] = array('params' => array('status' => CHWechatShopConst::ORDER_STATUS_ALL),
// 'result' => CHWechatShop::getOrderByStatus());
// // 获取所有货架
// $result['getAllShelf'] = array('params' => null,
// 'result' => CHWechatShop::getAllShelf());
// $result['shelfCreate'] = array('params' => array('shelf' => $shelf),
// 'result' => CHWechatShop::shelfCreate($shelf));
// if ($result['shelfCreate']['result']['errcode'] == 0) {
// $shelfId = $result['shelfCreate']['result']['shelf_id'];
// sleep(1);
// // 获取货架
// $result['getShelf'] = array('params' => array('shelfId' => $shelfId),
// 'result' => CHWechatShop::getShelf($shelfId));
// if ($result['getShelf']['result']['errcode'] == 0) {
// $shelf = new CHWechatShopShelf($result['getShelf']['result']);
// $shelf->removeShelfData()->addShelfData((new CHWechatShopShelfData1())->setProductCount(4)->setGroupId('416310720'))
// ->addShelfData((new CHWechatShopShelfData2())->addGroup('416488071')->addGroup('416488061')->addGroup('416310720'))
// ->addShelfData((new CHWechatShopShelfData3())->setGroupId('416488071')->setImage($image))
// ->addShelfData((new CHWechatShopShelfData4())->addGroup('416310720', $image)->addGroup('416488071', $image)->addGroup('416488061', $image));
// // 修改货架
// $result['shelfModify'] = array('params' => array('shelf' => $shelf),
// 'result' => CHWechatShop::shelfModify($shelf));
// }
// // 删除货架
// $result['shelfRemove'] = array('params' => array('shelfId' => $shelfId),
// 'result' => CHWechatShop::shelfRemove($shelfId));
// }
return $result;
}
}
?>