service = app('OwnerLogisticFeeReportService'); // $this->data['OwnerLogisticFeeDetail'] // = factory(\App\OwnerLogisticFeeDetail::class, $this->amount) // ->create([ // 'created_at' => now()->subMonth()->startOfMonth()->addDays(1), // 'province' => '北京', // 'initial_weight_price' => '20', // 'additional_price' => '20', // 'logistic_id' => '20', // ]); } public function testReturned() { $this->assertTrue(true); } function tearDown(): void { // OwnerLogisticFeeDetail::query() // ->whereIn('id', data_get($this->data['OwnerLogisticFeeDetail'], '*.id') ?? []) // ->delete(); parent::tearDown(); } /** * @test */ public function get_test() { OwnerLogisticFeeDetail::query()->truncate(); OwnerLogisticFeeReport::query()->truncate(); factory(OwnerLogisticFeeDetail::class)->create([ 'created_at' => now()->subMonth(), 'updated_at' => now()->subMonth(), 'province' => '北京', 'initial_weight' => '10', 'initial_weight_price' => '10', 'additional_price' => '10', 'additional_weight' => '10', 'logistic_id' => '1', 'owner_id' => '1', 'additional_weigh_weight' => '1', ]); factory(OwnerLogisticFeeDetail::class)->create([ 'created_at' => now()->subMonth(), 'updated_at' => now()->subMonth(), 'province' => '北京', 'initial_weight' => '10', 'initial_weight_price' => '10', 'additional_price' => '10', 'additional_weight' => '10', 'logistic_id' => '1', 'owner_id' => '1', 'additional_weigh_weight' => '1', ]); $this->service->recordReport(); $this->assertDatabaseHas('owner_logistic_fee_reports', [ 'logistic_id' => '1', 'province' => '北京', 'counted_date' => now()->subMonth()->startOfMonth()->toDateString(), 'initial_weight' => '10', 'initial_weight_price' => '10', 'initial_amount' => '2', 'additional_weight' => '10', 'additional_price' => '10', 'additional_amount' => '2', 'fee' => '40', 'owner_id' => '1', ]); } }