service = app(OrderService::class); // $this->data['owner'] = factory(Owner::class)->create(['name'=>'测试货主']); $wmsOrderHeader = factory(OracleDOCOrderHeader::class)->make([ 'customerid'=>'TEST_OW','sostatus'=>99,'userdefine1'=>'TEST_CA','warehouseid'=>'WH_TEST' ]); $orderType = factory(OracleBasCode::class)->make(['code'=>'sysy', 'codeid'=>'SO_TYP', 'codename_c'=>'测试状态']); $wmsOrderHeader->setRelation('orderType',$orderType); $code_BasCode = factory(OracleBasCode::class)->make(['codeid'=>'OW','code'=>'99','descr_c'=>'订单完成']); $wmsOrderHeader->setRelation('oracleBASCode',$code_BasCode); $this->data['orderHeader'] = $wmsOrderHeader; DB::insert('insert ignore into warehouses (code) values(?)',['WH_TEST']); $this->data['warehouse'] = Warehouse::query()->where('code','WH_TEST')->first(); DB::insert('insert ignore into logistics (code,name) values(?,?)',['TEST_CA','测试承运商']); $this->data['logistic'] = Logistic::query()->where('code','TEST_CA')->where('name','测试承运商')->first(); // $this->data['owner'] = factory(Owner::class)->create(['code'=>'TEST_OW','name'=>'测试货主']); DB::insert('insert ignore into owners (code,name) values(?,?)',['TEST_OW','测试货主']); $this->data['owner'] = Owner::query()->where('code','TEST_OW')->where('name','测试货主')->first(); $this->data['shop'] = factory(Shop::class)->create(['owner_id'=>$this->data['owner']['id']]); $this->mock(OracleDOCOrderHeaderService::class,function($mock)use($wmsOrderHeader){ $mock->shouldReceive('first')->andReturn($wmsOrderHeader); }); } /** * @test */ public function testGetParamByOrderHeader() { $orderHeader = $this->data['orderHeader'] ; $orderHeaders = collect([$orderHeader]); app(ShopService::class)->getByWmsOrders($orderHeaders); app(OwnerService::class)->getByWmsOrders($orderHeaders); app(LogisticService::class)->getByWmsOrders($orderHeaders); app(WarehouseService::class)->getByWmsOrders($orderHeaders); $param = $this->service->getParamByOrderHeader($orderHeader); $this->assertNotNull($param); $this->assertNotEmpty($param['code']); $this->assertNotEmpty($param['owner_id']); $this->assertNotNull($param['logistic_id']); // $this->assertNotEmpty($param['consignee_name']); // $this->assertNotEmpty($param['consignee_phone']); // $this->assertNotEmpty($param['province']); // $this->assertNotEmpty($param['city']); // $this->assertNotEmpty($param['district']); // $this->assertNotEmpty($param['address']); // $this->assertNotEmpty($param['client_code']); $this->assertNotEmpty($param['wms_edittime']); $this->assertNotEmpty($param['wms_status']); $this->assertNotEmpty($param['updated_at']); $this->assertNotEmpty($param['created_at']); $this->assertNotEmpty($param['warehouse_id']); } public function tearDown(): void { cache()->forget("getLogisticByCode_{$this->data['logistic']['code']}"); cache()->forget("getOwnerByCode_{$this->data['owner']['code']}"); cache()->forget("getShopByCodeMap_{$this->data['shop']['code']}"); cache()->forget("WareHouse_{$this->data['warehouse']['code']}"); // $order = Order::query()->where('code',$this->data['orderHeader']['orderno'])->first(); // $order->delete(); Shop::query()->where('owner_id',$this->data['owner']['id'])->delete(); Logistic::query()->where('code','TEST_CA')->where('name','测试承运商')->forceDelete(); Owner::query()->where('name','测试货主')->delete(); Warehouse::query()->where('code','WH_TEST')->delete(); parent::tearDown(); // TODO: Change the autogenerated stub } }