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