Update repository base code to be cleaner and make use of PHP 7 features

This commit is contained in:
Dane Everitt 2018-01-04 22:49:50 -06:00
parent 0ec5a4e08c
commit 60eb60013c
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
96 changed files with 1048 additions and 1785 deletions

View file

@ -68,14 +68,11 @@ class UserDeletionServiceTest extends TestCase
*/
public function testUserIsDeletedIfNoServersAreAttachedToAccount()
{
$this->serverRepository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
$this->serverRepository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
->shouldReceive('findCountWhere')->with([['owner_id', '=', $this->user->id]])->once()->andReturn(0);
$this->repository->shouldReceive('delete')->with($this->user->id)->once()->andReturn(true);
$this->repository->shouldReceive('delete')->with($this->user->id)->once()->andReturn(1);
$this->assertTrue(
$this->service->handle($this->user->id),
'Assert that service responds true.'
);
$this->assertEquals(1, $this->service->handle($this->user->id));
}
/**
@ -85,7 +82,7 @@ class UserDeletionServiceTest extends TestCase
*/
public function testExceptionIsThrownIfServersAreAttachedToAccount()
{
$this->serverRepository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
$this->serverRepository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
->shouldReceive('findCountWhere')->with([['owner_id', '=', $this->user->id]])->once()->andReturn(1);
$this->translator->shouldReceive('trans')->with('admin/user.exceptions.user_has_servers')->once()->andReturnNull();
@ -97,13 +94,10 @@ class UserDeletionServiceTest extends TestCase
*/
public function testModelCanBePassedInPlaceOfUserId()
{
$this->serverRepository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
$this->serverRepository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
->shouldReceive('findCountWhere')->with([['owner_id', '=', $this->user->id]])->once()->andReturn(0);
$this->repository->shouldReceive('delete')->with($this->user->id)->once()->andReturn(true);
$this->repository->shouldReceive('delete')->with($this->user->id)->once()->andReturn(1);
$this->assertTrue(
$this->service->handle($this->user),
'Assert that service responds true.'
);
$this->assertEquals(1, $this->service->handle($this->user));
}
}