perf: 使用更先进的 hdk 方法创建 http 请求

This commit is contained in:
李东云
2023-09-19 17:26:55 +08:00
parent 7401c97860
commit 4b5e1740bc
4 changed files with 61 additions and 39 deletions

View File

@@ -11,26 +11,25 @@ declare(strict_types=1);
*/
use Singularity\HDK\Core\Service\HttpRequestService;
use GuzzleHttp\Exception\GuzzleException;
use Singularity\HDK\Pay\Resource\Goods;
use Singularity\HDK\Pay\Sdk\GoodsRpc;
/** @var GoodsRpc $service */
$service = \Hyperf\Support\make(
GoodsRpc::class,
[
'requestService' => \Hyperf\Support\make(HttpRequestService::class),
'baseUri' => 'http://localhost:9611'
]);
test('根据分类和商品名称获取到对应的 SKU', function () use ($service) {
$goods = $service->find(
1,
[
'lattice' => 'TYPE-0',
'precision' => 'high',
'mode' => 'gradient',
],
);
expect($goods)->toBeInstanceOf(Goods::class);
})->only();
test(
'根据分类和商品名称获取到对应的 SKU',
/**
* @throws GuzzleException
*/
function () {
$service = new GoodsRpc('http://localhost:9611');
$goods = $service->find(
1,
[
'lattice' => 'TYPE-0',
'precision' => 'high',
'mode' => 'gradient',
],
);
expect($goods)->toBeInstanceOf(Goods::class);
}
);