Code cleanup to use new findCountWhere function

This commit is contained in:
Dane Everitt 2017-08-05 17:23:02 -05:00
parent c1a078bdcf
commit 4da7922de6
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 9 additions and 10 deletions

View file

@ -81,7 +81,8 @@ class DeletionServiceTest extends TestCase
*/
public function testUserIsDeletedIfNoServersAreAttachedToAccount()
{
$this->serverRepository->shouldReceive('findWhere')->with([['owner_id', '=', $this->user->id]])->once()->andReturn([]);
$this->serverRepository->shouldReceive('withColumns')->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->assertTrue(
@ -97,7 +98,8 @@ class DeletionServiceTest extends TestCase
*/
public function testExceptionIsThrownIfServersAreAttachedToAccount()
{
$this->serverRepository->shouldReceive('findWhere')->with([['owner_id', '=', $this->user->id]])->once()->andReturn(['item']);
$this->serverRepository->shouldReceive('withColumns')->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();
$this->service->handle($this->user->id);
@ -108,7 +110,8 @@ class DeletionServiceTest extends TestCase
*/
public function testModelCanBePassedInPlaceOfUserId()
{
$this->serverRepository->shouldReceive('findWhere')->with([['owner_id', '=', $this->user->id]])->once()->andReturn([]);
$this->serverRepository->shouldReceive('withColumns')->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->assertTrue(