<?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 GetByWmsTest extends TestCase
{
    /**
     * @var StoreService $service
     * @var OwnerService $ownerService
     * @var WarehouseService $warehouseService
     *
     */
    public $service;
    public $asnHeaders;
    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();
    }
    public function testGetParamsByAsnHeader()
    {
        if (empty($this->asnHeaders)) return null;
        $asnDetails=$this->service->getAsnDetailsByAsnHerder($this->asnHeaders);
        if(!$asnDetails){
            $storeItems=$this->service->getByWms($asnDetails);
            $this->assertNull($storeItems);
        }else{
            $storeItems=$this->service->getByWms($asnDetails);
            $this->assertNotNull($storeItems);
        }

    }
}
