service = app('OwnerService'); $owner = factory(Owner::class)->create(); $basCustomer = factory(OracleBasCustomer::class)->make(["customer_type"=>'OW',"customerid"=>$owner->code]); $this->data['basCustomers'] = $basCustomer; $this->data['owners'] = $owner; $this->mock('OracleBasCustomerService',function ($mock)use($basCustomer){ $mock->shouldReceive('first')->andReturn($basCustomer); }); } /** * @test */ public function getLogisticByCode() { $logistic = $this->service->getLogisticByCode(data_get($this->data['owners'],'*.code')); $this->assertEquals($logistic->id,$this->data['logistic']['id']); $this->assertEquals($logistic->code,$this->data['logistic']['code']); $this->assertEquals($logistic->name,$this->data['logistic']['name']); } public function tearDown(): void { cache()->forget('getLogisticByCode_'.$this->data['logistic']['code']); $this->data['logistic']->delete(); parent::tearDown(); // TODO: Change the autogenerated stub } }