RecordOrderDayTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace Tests\Services\NewOrderCountingRecordService;
  3. use App\Services\NewOrderCountingRecordService;
  4. use Carbon\Carbon;
  5. use Tests\TestCase;
  6. use App\OrderCountingRecord;
  7. use App\Traits\TestMockSubServices;
  8. class RecordOrderDayTest extends TestCase
  9. {
  10. use TestMockSubServices;
  11. /** @var NewOrderCountingRecordService $service */
  12. public $service;
  13. private $data;
  14. private $amount=2;
  15. function setUp(): void
  16. {
  17. parent::setUp();
  18. $this->service = app('NewOrderCountingRecordService');
  19. // $this->data['newOrderCountingRecords']
  20. // = factory(OrderCountingRecord::class, $this->amount)
  21. // ->create();
  22. }
  23. public function testReturned()
  24. {
  25. $this->assertTrue(true);
  26. }
  27. function tearDown(): void
  28. {
  29. OrderCountingRecord::query()
  30. ->whereIn('id',data_get($this->data['newOrderCountingRecords'],'*.id')??[])
  31. ->delete();
  32. parent::tearDown();
  33. }
  34. /**
  35. * @test
  36. */
  37. // public function record_test()
  38. // {
  39. // $start = '2021-05-14';
  40. // $end = '2021-06-08';
  41. // $this->service->recordByDay($start, $end, '日');
  42. // $startDateTime = Carbon::parse($start)->startOfDay()->toDateTimeString();
  43. // $endDateTime = now()->subDay()->endOfDay()->toDateTimeString();
  44. //
  45. // $orderCount = \App\Order::query()
  46. // ->whereBetween('created_at', [$startDateTime, $endDateTime])
  47. // ->where('wms_status', '订单完成')
  48. // ->count();
  49. // //TODO 只能使用Date!!!!
  50. // $sum = OrderCountingRecord::query()
  51. // ->whereBetween('date_target', [Carbon::parse($startDateTime)->toDateString(), Carbon::parse($endDateTime)->toDateString()])
  52. // ->sum('amount');
  53. // $this->assertEquals($sum,
  54. // $orderCount);
  55. // }
  56. }