<?php


namespace Tests\Inventory\Services\InventoryAccountService;


use App\InventoryAccount;
use App\InventoryAccountMission;
use App\Services\InventoryAccountService;
use Tests\TestCase;

class InventoryServiceCreateInventoryMissionRecordTest extends TestCase
{

    public $inventory;
    public $inventoryMissions;
    public $realService;
    public $wmsInventoryAccounts;
    function setUp(): void
    {
        parent::setUp();
        $this->inventory=factory(InventoryAccount::class)->create();
        $this->realService=new InventoryAccountService();
        $this->wmsInventoryAccounts=$this->realService->conditionPortStock('2020-08-20','2020-08-20',3,'','');
    }
        function testCreateInventoryMissionsFail(){
        $inventoryMissions= $this->realService->createInventoryAccountMissionRecord('',$this->inventory['id'],$this->wmsInventoryAccounts);
        $this->assertNull($inventoryMissions);
    }
    function testCreateInventoryMissionsSuccess(){
        $this->realService->createInventoryAccountMissionRecord(3,$this->inventory['id'],$this->wmsInventoryAccounts);
        $this->inventoryMissions=InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->get();
        $this->assertNotNull($this->inventoryMissions);
    }
    function tearDown(): void
    {
        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
        InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
        parent::tearDown(); // TODO: Change the autogenerated stub
    }


}


//function testMock(){
//    $realService=new InventoryService();
//    $mockService=$this->createMock(InventoryService=>=>class);
//    $mockService->method('conditionSearch')->willReturn(new Collection(['a'=>'11','b'=>22]));
//    $mockService->method('createInventoryMissionRecord')->willReturn($realService->createInventoryMissionRecord(11,22,33));
//    $this->assertEquals(2,$mockService->createInventoryMissionRecord());
//}
//$array=[
//    0 => [
//        "货主"=>"金宝贝",
//        "客户"=> "JINBAOBEI",
//        "库位"=> "G08-05-01",
//        "产品编码"=> "900317006-ORANGE",
//        "产品条码"=> "240041417",
//        "商品名称"=> "麦克风橙色",
//        "属性仓"=> "JBB-ZP",
//        "质量状态"=> "ZP",
//        "失效日期"=> null,
//        "批号"=> null,
//        "生产日期"=> null,
//        "入库日期"=> null,
//        "移出数量"=> "3",
//        "移入数量"=> "0",
//        "在库数量"=> "745",
//        "占用数量"=> "0",
//        "sum"=> "6954",
//        "rn"=> "1",
//    ],
//    1 => [
//        "货主"=> "金宝贝",
//        "客户"=> "JINBAOBEI",
//        "库位"=> "G05-20-03",
//        "产品编码"=> "8809465536572",
//        "产品条码"=> "8809465536572",
//        "商品名称"=> "STICK-O益智磁力片金宝核心套组",
//        "属性仓"=> "JBB-ZP",
//        "质量状态"=> "ZP",
//        "失效日期"=> null,
//        "批号"=> null,
//        "生产日期"=> null,
//        "入库日期"=> null,
//        "移出数量"=> "22",
//        "移入数量"=> "0",
//        "在库数量"=> "98",
//        "占用数量"=> "5",
//        "sum"=> "6954",
//        "rn"=> "2",
//    ],
//    2 => [
//        "货主"=> "金宝贝",
//        "客户"=> "JINBAOBEI",
//        "库位"=> "G08-28-01",
//        "产品编码"=> "6972392150141",
//        "产品条码"=> "6972392150141",
//        "商品名称"=> "皆蓝迪雅婴儿泡沫免洗洗手液 50ml",
//        "属性仓"=> null,
//        "质量状态"=> "ZP",
//        "失效日期"=> "2023-04-19",
//        "批号"=> "20DZK1Y01",
//        "生产日期"=> null,
//        "入库日期"=> null,
//        "移出数量"=> "0",
//        "移入数量"=> "10000",
//        "在库数量"=> null,
//        "占用数量"=> null,
//        "sum"=> "6954",
//        "rn"=> "3",
//    ],
//];




