<?php


namespace Tests\Services\StoreService;


use App\OracleDOCASNHeader;
use App\Services\OwnerService;
use App\Services\StoreItemService;
use App\Services\StoreService;
use App\Services\WarehouseService;
use App\Store;
use Carbon\Carbon;
use Tests\TestCase;

class GetAsnDetailsByAsnHerderTest extends TestCase
{
    /**
     * @var StoreService $service
     * @var OwnerService $ownerService
     * @var WarehouseService $warehouseService
     *
     */
    public $service;
    public $asnHeaders;
    public $asnHeadersEdit;
    public function setUp(): void
    {
        parent::setUp(); // TODO: Change the autogenerated stub
        $startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
        $this->service=app(StoreItemService::class);
        $this->asnHeaders=OracleDOCASNHeader::query()
            ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
                $query->with(['lineStatus', 'qualityStatus','basSku']);
            }])
            ->where('addTime', '>=', $startDate)
            ->get();
        $this->asnHeadersEdit=OracleDOCASNHeader::query()
            ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
                $query->with(['lineStatus', 'qualityStatus','basSku']);
            }])
            ->where('EditTime', '>=',  $startDate)
            ->whereColumn('EditTime', '<>', 'addTime')
            ->get();
    }
    public function testGetAsnDetailsByAsnHerder(){
        ini_set('memory_limit','512M');
        if (empty($this->asnHeaders))return null;
        $asnDetails=$this->service->getAsnDetailsByAsnHerder($this->asnHeaders);
        $this->assertNotEmpty($asnDetails);
        if (empty($this->asnDetailsEdit))return null;
        $asnDetailsEdit=$this->service->getAsnDetailsByAsnHerder($this->asnHeadersEdit);
        $this->assertNotEmpty($asnDetailsEdit);
    }
}
