service=app('OrderService'); $orderHeader = new OracleDOCOrderHeader(); $orderHeader->orderno = md5('订单编号'); $orderHeader->c_contact= '京东旗舰店'; $orderHeader->c_tel2 = md5('承运商'); $orderHeader->c_province = md5('收货人'); $orderHeader->c_city = md5('shou'); $orderHeader->c_district = md5('shou'); $orderHeader->c_address1 = md5('shou'); $orderHeader->soreference1 = md5('客户订单号'); $orderHeader->userdefine1 = $this->data['userdefine1']; $orderHeader->warehouseid = $this->data['warehouse_code']; $orderHeader->customerid = $this->data['customerid']; $orderHeader->issuepartyname =$this->data['issuepartyname']; $orderHeader->setAppends(['orderType'=>['codename_c'=>$this->data['orderType']]]); $this->data['logistic'] = Logistic::query()->firstOrCreate(['code'=>$this->data['userdefine1'],'name'=>'测试物流']); $this->data['owner'] = Owner::query()->firstOrCreate(['code'=>$this->data['customerid'],'name'=>'测试货主']); $this->data['shop'] =Shop::query()->firstOrCreate(['name'=>$this->data['issuepartyname'],'owner_id'=>$this->data['owner']->id]); $this->data['warehouse'] = Warehouse::query()->firstOrCreate(["code"=>$this->data['warehouse_code'],"name"=>'测试仓库']); } /** * @test */ public function findOrCreateByClientCode() { $clientCode = OracleDOCOrderHeader::query() ->orderByDesc('AddTime') ->where('sostatus',99) ->first() ->soreference1; $order = $this->service->findOrCreateByClientCode($clientCode); $this->assertNotEmpty($clientCode); $this->assertNotEmpty($order); $this->assertNotNull($order->client_code); $this->assertNotNull($order->warehouse_id); } public function tearDown(): void { cache()->flush(); $this->data['logistic']->delete(); $this->data['owner']->delete(); $this->data['shop']->delete(); $this->data['warehouse']->delete(); Order::query()->where('code',$this->data['orderHeader']['orderno'])->delete(); parent::tearDown(); // TODO: Change the autogenerated stub } }