<?php

namespace Tests\Unit;

use App\Order;
use App\OrderIssue;
use App\OrderPackage;
use Tests\TestCase;

class OrderPackageTest extends TestCase
{
    protected $order;
    protected $orderPackage;
    protected $orderIssue;

    protected function tearDown(): void
    {
        $this->order->delete();
        $this->orderPackage->delete();
        $this->orderIssue->delete();
        parent::tearDown(); // TODO: Change the autogenerated stub
    }


    /**
     * A basic unit test example.
     *
     * @return void
     */
    public function testExample()
    {
        $this->assertTrue(true);
    }

    /**
     * @test
     */
    public function has_one_through_order_issue()
    {
        $order = factory(Order::class)->create();
        $orderPackage = factory(OrderPackage::class)->create(['order_id' =>$order->id]);
        $orderIssue = factory(OrderIssue::class)->create(['order_id' =>$order->id]);
        dd($orderPackage->refresh()->loadMissing('order.issue')->toArray());
    }
}
