| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace Tests\Services\NewOrderCountingRecordService;
- use App\Services\NewOrderCountingRecordService;
- use Tests\TestCase;
- use App\OrderCountingRecord;
- use App\Traits\TestMockSubServices;
- class RecordByMonthTest extends TestCase
- {
- use TestMockSubServices;
- /** @var NewOrderCountingRecordService $service */
- public $service;
- private $data;
- private $amount = 2;
- function setUp(): void
- {
- parent::setUp();
- $this->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 get_test()
- {
- $start = '2021-05-01';
- $startDate = $start;
- $endDate = \Carbon\Carbon::parse($start)->endOfMonth()->toDateString();
- $this->service->recordByMonth($start);
- $this->assertEquals(OrderCountingRecord::query()
- ->whereBetween('date_target', [$startDate, $endDate])
- ->where('counting_unit','日')
- ->sum('amount'), OrderCountingRecord::query()
- ->where('counting_unit','月')
- ->where('month','2021-5')
- ->sum('amount'));
- $this->assertTrue(true);
- }
- }
|