| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace Tests\Services\OwnerStoreOutFeeReportService;
- use App\OwnerBillReport;
- use App\OwnerFeeDetail;
- use App\OwnerPriceOperation;
- use App\OwnerStoreFeeDetail;
- use App\OwnerStoreFeeReport;
- use App\OwnerStoreOutFeeDetail;
- use App\Services\OwnerStoreOutFeeReportService;
- use Tests\TestCase;
- use App\OwnerStoreOutFeeReport;
- use App\Traits\TestMockSubServices;
- class RecordReportTest extends TestCase
- {
- use TestMockSubServices;
- /** @var OwnerStoreOutFeeReportService $service */
- public $service;
- private $data;
- private $amount = 2;
- function setUp(): void
- {
- parent::setUp();
- $this->service = app('OwnerStoreOutFeeReportService');
- }
- public function test_record()
- {
- OwnerStoreOutFeeReport::query()->truncate();
- OwnerFeeDetail::query()->truncate();
- OwnerPriceOperation::query()->truncate();
- OwnerStoreOutFeeDetail::query()->truncate();
- $ownerFeeDetails = factory(OwnerFeeDetail::class)->times(10)->create();
- $ownerPriceOperations = factory(OwnerPriceOperation::class)->times(2)->create();
- $ownerStoreOutFeeDetails = [];
- foreach ($ownerFeeDetails as $ownerFeeDetail) {
- $id = $ownerPriceOperations->random(1)[0]->id;
- $ownerStoreOutFeeDetails[] = factory(OwnerStoreOutFeeDetail::class)->create([
- 'owner_fee_detail_id' => $ownerFeeDetail->id,
- 'owner_id' => 8,
- 'owner_price_operation_id' => $id,
- ]);
- $ownerStoreOutFeeDetails[] = factory(OwnerStoreOutFeeDetail::class)->create([
- 'owner_fee_detail_id' => $ownerFeeDetail->id,
- 'owner_id' => 8,
- 'owner_price_operation_id' => $id,
- ]);
- }
- $this->service->recordReport();
- $this->assertEquals(collect($ownerFeeDetails)->sum('work_fee'), OwnerStoreOutFeeReport::query()->sum('fee'));
- }
- function tearDown(): void
- {
- parent::tearDown();
- }
- }
|