-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 新增 OrderStandardFlowTest 测试类,实现标准订单创建和支付的端到端测试 - 修改 OrderFake 类,增加单位和数量字段,用于测试订单商品信息 - 更新 TestCase 基类,设置测试环境配置和用户认证 - 在 composer.json 中添加 pest 测试命令 - 调整 phpunit.xml 和 testbench.yaml,配置测试环境
- Loading branch information
1 parent
f1b071c
commit 61e00d5
Showing
8 changed files
with
109 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'<?php | ||
|
||
|
||
use RedJasmine\Order\Application\Services\OrderCommandService; | ||
use RedJasmine\Order\Application\UserCases\Commands\OrderCreateCommand; | ||
use RedJasmine\Order\Application\UserCases\Commands\OrderPayingCommand; | ||
use RedJasmine\Order\Domain\Events\OrderPayingEvent; | ||
use RedJasmine\Order\Domain\Models\Enums\OrderTypeEnum; | ||
use RedJasmine\Order\Domain\Models\Order; | ||
use RedJasmine\Order\Domain\Models\OrderPayment; | ||
use RedJasmine\Tests\Feature\Order\Fixtures\OrderFake; | ||
|
||
|
||
beforeEach(function () { | ||
|
||
$this->orderCommandService = app(OrderCommandService::class); | ||
// | ||
}); | ||
|
||
test('can crate a new order', function () { | ||
|
||
$orderFake = new OrderFake(); | ||
$orderFake->orderType = OrderTypeEnum::STANDARD; | ||
$command = OrderCreateCommand::from($orderFake->order()); | ||
|
||
|
||
$result = $this->orderCommandService->create($command); | ||
|
||
$this->assertInstanceOf(Order::class, $result, '创建订单失败'); | ||
|
||
|
||
$this->order = $result; | ||
|
||
return $result; | ||
}); | ||
|
||
|
||
test('cna paying a order', function (Order $order) { | ||
|
||
|
||
Event::fake(); | ||
|
||
$command = OrderPayingCommand::from( | ||
[ | ||
'id' => $order->id, | ||
'amount' => $order->payable_amount | ||
|
||
] | ||
|
||
); | ||
|
||
|
||
$result = $this->orderCommandService->paying($command); | ||
|
||
\Illuminate\Support\Facades\Event::assertDispatched(OrderPayingEvent::class, null); | ||
|
||
$this->assertInstanceOf(OrderPayment::class, $result, '创建支付记录失败'); | ||
|
||
|
||
return $result; | ||
|
||
})->depends('can crate a new order'); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters