<?php

namespace Tests\Services\OrderTrakingSerive\CustomizedOperationTest;

use App\OracleDOCOrderHeader;
use App\Services\OrderTrackingService;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Collection;
use Tests\TestCase;

class CustomizedOperationTest extends TestCase
{
    /** @var OrderTrackingService $service */
    public $service;

    public function setUp(): void
    {
        $this->service=app(OrderTrackingService::class);
        parent::setUp();
    }

    public function testCustomizedOperation()
    {
        $carbon = Carbon::now()->subHours(12);
        $orderHeaders = OracleDOCOrderHeader::query()->where('consigneeid',"ZT")->where('addtime',$carbon)->get();
        $ZT_Count = $orderHeaders->count();
        /** @var Collection $orderHeader */
        $orderHeader = $this->service->customizedOperation($orderHeaders);
        $XJ_Count  = $orderHeaders->filter(function($orderHeader){
            return $orderHeader->userdefine1 == 'XJWL';
        })->count();
//        var_dump($orderHeaders->count(),$carbon);
//        $this->assertNotEmpty($orderHeaders);
        $this->assertEquals($ZT_Count,$XJ_Count);
    }
}
