<?php

namespace Tests\Services\WarehouseService\GetByWmsOrdersTest;

use App\OracleBasCustomer;
use App\OracleDOCOrderHeader;
use App\Services\WarehouseService;
use App\Warehouse;
use Carbon\Carbon;
use Tests\TestCase;

class GetByWmsOrderTest extends TestCase
{

    /** @var WarehouseService $service */
    public $service;
    public $data = [];

    public function setUp(): void
    {
        parent::setUp();
        $this->service = app(WarehouseService::class);
        $basCustomers = OracleBasCustomer::query()->selectRaw('Customer_Type,CustomerId,Descr_C')->where('Customer_Type','WH')->get();
        foreach ($basCustomers as $basCustomer) {
            $this->data['data'][]['warehouseid'] =  $basCustomer->customerid;
        }
    }

    public function testGetByWmsOrder()
    {
        $warehouses =  $this->service->getByWmsOrders($this->data['data']);
        $warehouse_ids = data_get($this->data['data'],'*.warehouseid');
        $warehouse_s = Warehouse::query()->whereIn('code',$warehouse_ids)->get();
        $this->assertEquals($warehouses->count(),$warehouse_s->count());
    }
}
