<?php

namespace Tests\Services\OrderService;

use App\OracleDOCOrderHeader;
use App\Order;
use App\Owner;
use App\Services\OrderService;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Str;
use Tests\TestCase;

class CreateOrFindOrderInfoTest extends TestCase
{

    /**
     * @var OrderService $orderService
     * @var Order $order
     */
    public $orderService;
    public $data = [];
    public $order ;
    public function setUp(): void
    {
        parent::setUp(); // TODO: Change the autogenerated stub
        $this->orderService = app('OrderService');
        $this->data['orderHeader'] = OracleDOCOrderHeader::query()->orderBy('addTime')->first();
    }
    public function testCreateOrFindOrderInfo()
    {
        $this->orderService->createOrFindOrderInfo($this->data['orderHeader']);
        $order =Order::query()->where('code',$this->data['orderHeader']['orderno'])->first();
        $this->assertNotNull($order);
        $this->order = $order;
        $this->assertEquals($order->code,$this->data['orderHeader']['orderno']);
        $this->order->delete();
    }

    public function testCreateOrFindOrderInfo1()
    {
        $orderHeader = $this->data['orderHeader'];
        $orderHeader->customerid = null;
        $orderHeader->warehouseid = null;
        $orderHeader->userdefine1 = null;
        $this->orderService->createOrFindOrderInfo($this->data['orderHeader']);

    }

}
