RecordByMonthTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Tests\Services\NewOrderCountingRecordService;
  3. use App\Services\NewOrderCountingRecordService;
  4. use Tests\TestCase;
  5. use App\OrderCountingRecord;
  6. use App\Traits\TestMockSubServices;
  7. class RecordByMonthTest extends TestCase
  8. {
  9. use TestMockSubServices;
  10. /** @var NewOrderCountingRecordService $service */
  11. public $service;
  12. private $data;
  13. private $amount = 2;
  14. function setUp(): void
  15. {
  16. parent::setUp();
  17. $this->service = app('NewOrderCountingRecordService');
  18. // $this->data['newOrderCountingRecords']
  19. // = factory(OrderCountingRecord::class, $this->amount)
  20. // ->create();
  21. }
  22. public function testReturned()
  23. {
  24. $this->assertTrue(true);
  25. }
  26. function tearDown(): void
  27. {
  28. OrderCountingRecord::query()
  29. ->whereIn('id', data_get($this->data['newOrderCountingRecords'], '*.id') ?? [])
  30. ->delete();
  31. parent::tearDown();
  32. }
  33. /**
  34. * @test
  35. */
  36. // public function get_test()
  37. // {
  38. // $start = '2021-05-01';
  39. // $startDate = $start;
  40. // $endDate = \Carbon\Carbon::parse($start)->endOfMonth()->toDateString();
  41. // $this->service->recordByMonth($start);
  42. // $this->assertEquals(OrderCountingRecord::query()
  43. // ->whereBetween('date_target', [$startDate, $endDate])
  44. // ->where('counting_unit','日')
  45. // ->sum('amount'), OrderCountingRecord::query()
  46. // ->where('counting_unit','月')
  47. // ->where('month','2021-5')
  48. // ->sum('amount'));
  49. // $this->assertTrue(true);
  50. // }
  51. }