<?php

namespace Tests\Services\OracleDOCOrderHeaderService\GetWMSORderOnStartDateTest;

use App\OracleDOCOrderHeader;
use App\OrderTrackingOwner;
use App\Owner;
use App\Services\OracleDOCOrderHeaderService;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class GetWMSOrderOnStartDateTest extends TestCase
{
    /** @var OracleDOCOrderHeaderService $service */
    public $service;

    public function setUp(): void
    {
        parent::setUp();
        $this->service = app(OracleDOCOrderHeaderService::class);
        factory(OrderTrackingOwner::class)->create([
            'owner_id'=>factory(Owner::class)->create(['user_owner_group_id'=>null,'code'=>'WANLING'])->id,
            'status'=>'启用']);
    }

    /**
     * @test
     */
    public function getWMSOrderOnStartDate()
    {
        $orderHeader = OracleDOCOrderHeader::query()->orderByDesc('addTime')->first();
        if(!$orderHeader){
            $this->assertNull($orderHeader);
            return ;
        }
        $carbon =Carbon::parse($orderHeader->addtime)->subMinutes(5);
        $orderHeaders = $this->service->getWMSOrderOnStartDate($carbon);
        $this->assertNotNull($orderHeaders);
        $orderHeader = $orderHeaders->first();
        $this->assertNotNull($orderHeader);
    }

}
