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

@ -62,14 +62,11 @@ class NodeDeletionServiceTest extends TestCase
*/
public function testNodeIsDeletedIfNoServersAreAttached()
{
$this->serverRepository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
$this->serverRepository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
->shouldReceive('findCountWhere')->with([['node_id', '=', 1]])->once()->andReturn(0);
$this->repository->shouldReceive('delete')->with(1)->once()->andReturn(true);
$this->repository->shouldReceive('delete')->with(1)->once()->andReturn(1);
$this->assertTrue(
$this->service->handle(1),
'Assert that deletion returns a positive boolean value.'
);
$this->assertEquals(1, $this->service->handle(1));
}
/**
@ -79,7 +76,7 @@ class NodeDeletionServiceTest extends TestCase
*/
public function testExceptionIsThrownIfServersAreAttachedToNode()
{
$this->serverRepository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
$this->serverRepository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
->shouldReceive('findCountWhere')->with([['node_id', '=', 1]])->once()->andReturn(1);
$this->translator->shouldReceive('trans')->with('exceptions.node.servers_attached')->once()->andReturnNull();
$this->repository->shouldNotReceive('delete');
@ -94,13 +91,10 @@ class NodeDeletionServiceTest extends TestCase
{
$node = factory(Node::class)->make();
$this->serverRepository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
$this->serverRepository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
->shouldReceive('findCountWhere')->with([['node_id', '=', $node->id]])->once()->andReturn(0);
$this->repository->shouldReceive('delete')->with($node->id)->once()->andReturn(true);
$this->repository->shouldReceive('delete')->with($node->id)->once()->andReturn(1);
$this->assertTrue(
$this->service->handle($node),
'Assert that deletion returns a positive boolean value.'
);
$this->assertEquals(1, $this->service->handle($node));
}
}