2023-09-07 14:18:40 +08:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Author: ykxiao
|
|
|
|
* Date: 2023/9/6
|
|
|
|
* Time: 19:49
|
|
|
|
* Description: 工单测试类
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Feature;
|
|
|
|
|
|
|
|
use GuzzleHttp\Client;
|
2023-09-08 10:42:34 +08:00
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
|
|
|
use GuzzleHttp\Psr7\Response;
|
|
|
|
use Mockery;
|
2023-09-07 14:18:40 +08:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Ykxiao\Dmmes\OrderActions\Order;
|
|
|
|
|
|
|
|
class OrderTest extends TestCase
|
|
|
|
{
|
2023-09-08 10:42:34 +08:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @throws GuzzleException
|
|
|
|
*/
|
|
|
|
public function testGetProductOrder()
|
2023-09-07 14:18:40 +08:00
|
|
|
{
|
2023-09-08 10:42:34 +08:00
|
|
|
$response = new Response(200, [], '{"success": true}');
|
2023-09-07 14:18:40 +08:00
|
|
|
|
2023-09-08 10:42:34 +08:00
|
|
|
// 创建模拟 http client。
|
|
|
|
$client = Mockery::mock(Client::class);
|
2023-09-07 14:18:40 +08:00
|
|
|
|
2023-09-08 10:42:34 +08:00
|
|
|
$client->allows()->post('https://api.dev.dwoodauto.com/api/v3/production.status', [
|
|
|
|
'signature' => 'eretgfdsa34565432b453',
|
|
|
|
'data' => ['order_sn' => 'w45676543456']
|
|
|
|
])->andReturn($response);
|
2023-09-07 14:18:40 +08:00
|
|
|
|
2023-09-08 10:42:34 +08:00
|
|
|
$w = Mockery::mock(Order::class, ['mock-key'])->makePartial();
|
2023-09-07 14:18:40 +08:00
|
|
|
|
2023-09-08 10:42:34 +08:00
|
|
|
$w->allows()->getHttpClient()->andReturn($client); // $client 为上面创建的模拟实例。
|
2023-09-07 15:30:08 +08:00
|
|
|
|
2023-09-08 10:42:34 +08:00
|
|
|
$this->assertSame('', '');
|
2023-09-07 15:30:08 +08:00
|
|
|
}
|
2023-09-07 14:18:40 +08:00
|
|
|
}
|