<?php

namespace Tests\Services\OracleDOCOrderHeaderService;

use App\OracleDOCOrderHeader;
use App\Services\OracleDOCOrderHeaderService;
use App\Services\OrderService;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class GetWMSOrderOnEditDateTest extends TestCase
{
    /** @var OracleDOCOrderHeaderService $service */
    private $service;

    public function setUp(): void
    {
        parent::setUp(); // TODO: Change the autogenerated stub
        $this->service = app('OracleDocOrderHeaderService');
    }

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