service = app('NewOrderCountingRecordService'); // $this->data['newOrderCountingRecords'] // = factory(OrderCountingRecord::class, $this->amount) // ->create(); } public function testReturned() { $this->assertTrue(true); } function tearDown(): void { OrderCountingRecord::query() ->whereIn('id',data_get($this->data['newOrderCountingRecords'],'*.id')??[]) ->delete(); parent::tearDown(); } /** * @test */ public function record_test() { $start = '2021-05-14'; $end = '2021-06-08'; $this->service->recordByDay($start, $end, '日'); $startDateTime = Carbon::parse($start)->startOfDay()->toDateTimeString(); $endDateTime = now()->subDay()->endOfDay()->toDateTimeString(); $orderCount = \App\Order::query() ->whereBetween('created_at', [$startDateTime, $endDateTime]) ->where('wms_status', '订单完成') ->count(); //TODO 只能使用Date!!!! $sum = OrderCountingRecord::query() ->whereBetween('date_target', [Carbon::parse($startDateTime)->toDateString(), Carbon::parse($endDateTime)->toDateString()]) ->sum('amount'); $this->assertEquals($sum, $orderCount); } }