| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace Tests\Services\OwnerLogisticFeeReportService;
- use App\OwnerLogisticFeeDetail;
- use App\Services\OwnerLogisticFeeReportService;
- use Tests\TestCase;
- use App\OwnerLogisticFeeReport;
- use App\Traits\TestMockSubServices;
- class RecordReportTest extends TestCase
- {
- use TestMockSubServices;
- /** @var OwnerLogisticFeeReportService $service */
- public $service;
- private $data;
- private $amount = 2;
- function setUp(): void
- {
- parent::setUp();
- $this->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',
- ]);
- }
- }
|