<?php

namespace Tests\Services\OracleDOCOrderHeaderService;

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

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

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

    /**
     * @test
     */
    public function getWmsOrderOnStartDateCreate()
    {
        $carbon =Carbon::now()->subHours(10);
        $orderHeaders = $this->service->getWmsOrderOnStartDateCreate($carbon);
        $this->assertNotNull($orderHeaders);
        $orderHeader = $orderHeaders->first();
        if($orderHeaders->count() == 0){
            return ;
        }
        $this->assertNotNull($orderHeader->oracleDOCOrderDetails);
        $this->assertNotNull($orderHeader->actAllocationDetails);
        $this->assertNotNull($orderHeader->oracleBASCustomer);
        $this->assertNotNull($orderHeader->oracleBASCode);
    }
}
