<?php

namespace Tests\Services\OrderService;

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

class CreateOrFindOrderTest extends TestCase
{
    /**
     * @var OrderService $orderService
     */
    public $orderService;
    public $data = [];
    public $order ;
    public function setUp(): void
    {
        parent::setUp();
        $this->orderService = app('OrderService');
        $this->data['orderHeader'] = OracleDOCOrderHeader::query()->orderBy('addTime')->first();
    }

    public function testExample()
    {
        $this->orderService->createOrFindOrder($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();
    }
}
