flush(); $basCustomer = factory(OracleBasCustomer::class)->make([]); $this->data['owner'] = factory(Owner::class)->create(); $this->data['basCustomer'] = $basCustomer; $this->service = app('OwnerService'); $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']); } /** * @test */ public function ownerIsNotExist() { $this->data['owner']->delete(); $owner = $this->service->getOwnerByCode($this->data['owner']['code']); $this->assertEquals($owner->code,$this->data['basCustomer']['customerid']); $this->assertEquals($owner->name,$this->data['basCustomer']['descr_c']); $this->data['owner']= $owner; } public function tearDown(): void { cache()->flush(); $this->data['owner']->delete(); parent::tearDown(); // TODO: Change the autogenerated stub } }