feat: 初步实现了获取单个商品的方法

This commit is contained in:
李东云
2023-07-25 14:50:12 +08:00
parent 68d898d177
commit 196ea4d8bf
7 changed files with 502 additions and 201 deletions

View File

@@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
namespace Tests\Example;
use PHPUnit\Framework\TestCase;
use Example\Greeting;
class GreetingTest extends TestCase
{
public function testItGreetsUser(): void
{
$greeting = new Greeting('Rasmus Lerdorf');
$this->assertSame('Hello Rasmus Lerdorf', $greeting->sayHello());
}
}

36
tests/Unit/GoodsTest.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* GoodsTest.php@LuxPay
*
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
* Powered by PhpStorm
* Created on 2023/7/18
*/
use Singularity\HDK\Core\Service\HttpRequestService;
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();