Update repository base code to be cleaner and make use of PHP 7 features
This commit is contained in:
parent
0ec5a4e08c
commit
60eb60013c
96 changed files with 1048 additions and 1785 deletions
|
@ -116,7 +116,7 @@ class ServerCreationServiceTest extends TestCase
|
|||
'egg_id' => $model->egg_id,
|
||||
]))->once()->andReturn($model);
|
||||
|
||||
$this->allocationRepository->shouldReceive('assignAllocationsToServer')->with($model->id, [$model->allocation_id])->once()->andReturnNull();
|
||||
$this->allocationRepository->shouldReceive('assignAllocationsToServer')->with($model->id, [$model->allocation_id])->once()->andReturn(1);
|
||||
|
||||
$this->validatorService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_ADMIN)->once()->andReturnNull();
|
||||
$this->validatorService->shouldReceive('handle')->with($model->egg_id, [])->once()->andReturn(
|
||||
|
@ -129,7 +129,7 @@ class ServerCreationServiceTest extends TestCase
|
|||
'variable_id' => 123,
|
||||
'variable_value' => 'var1-value',
|
||||
],
|
||||
])->once()->andReturnNull();
|
||||
])->once()->andReturn(true);
|
||||
$this->configurationStructureService->shouldReceive('handle')->with($model)->once()->andReturn(['test' => 'struct']);
|
||||
|
||||
$this->daemonServerRepository->shouldReceive('setNode')->with($model->node_id)->once()->andReturnSelf();
|
||||
|
@ -154,7 +154,7 @@ class ServerCreationServiceTest extends TestCase
|
|||
|
||||
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('create')->once()->andReturn($model);
|
||||
$this->allocationRepository->shouldReceive('assignAllocationsToServer')->once()->andReturnNull();
|
||||
$this->allocationRepository->shouldReceive('assignAllocationsToServer')->once()->andReturn(1);
|
||||
$this->validatorService->shouldReceive('setUserLevel')->once()->andReturnNull();
|
||||
$this->validatorService->shouldReceive('handle')->once()->andReturn(collect([]));
|
||||
$this->configurationStructureService->shouldReceive('handle')->once()->andReturn([]);
|
||||
|
|
|
@ -116,13 +116,13 @@ class ServerDeletionServiceTest extends TestCase
|
|||
->shouldReceive('delete')->withNoArgs()->once()->andReturnNull();
|
||||
|
||||
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
|
||||
$this->databaseRepository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
|
||||
$this->databaseRepository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
|
||||
->shouldReceive('findWhere')->with([
|
||||
['server_id', '=', $this->model->id],
|
||||
])->once()->andReturn(collect([(object) ['id' => 50]]));
|
||||
|
||||
$this->databaseManagementService->shouldReceive('delete')->with(50)->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('delete')->with($this->model->id)->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('delete')->with($this->model->id)->once()->andReturn(1);
|
||||
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
|
||||
$this->service->handle($this->model);
|
||||
|
@ -140,13 +140,13 @@ class ServerDeletionServiceTest extends TestCase
|
|||
$this->exception->shouldReceive('getResponse')->withNoArgs()->once()->andReturnNull();
|
||||
$this->writer->shouldReceive('warning')->with($this->exception)->once()->andReturnNull();
|
||||
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
|
||||
$this->databaseRepository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
|
||||
$this->databaseRepository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
|
||||
->shouldReceive('findWhere')->with([
|
||||
['server_id', '=', $this->model->id],
|
||||
])->once()->andReturn(collect([(object) ['id' => 50]]));
|
||||
|
||||
$this->databaseManagementService->shouldReceive('delete')->with(50)->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('delete')->with($this->model->id)->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('delete')->with($this->model->id)->once()->andReturn(1);
|
||||
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
|
||||
$this->service->withForce()->handle($this->model);
|
||||
|
@ -176,21 +176,21 @@ class ServerDeletionServiceTest extends TestCase
|
|||
*/
|
||||
public function testIntegerCanBePassedInPlaceOfServerModel()
|
||||
{
|
||||
$this->repository->shouldReceive('withColumns')->with(['id', 'node_id', 'uuid'])->once()->andReturnSelf()
|
||||
$this->repository->shouldReceive('setColumns')->with(['id', 'node_id', 'uuid'])->once()->andReturnSelf()
|
||||
->shouldReceive('find')->with($this->model->id)->once()->andReturn($this->model);
|
||||
|
||||
$this->daemonServerRepository->shouldReceive('setNode')->with($this->model->node_id)->once()->andReturnSelf()
|
||||
->shouldReceive('setAccessServer')->with($this->model->uuid)->once()->andReturnSelf()
|
||||
->shouldReceive('delete')->withNoArgs()->once()->andReturnNull();
|
||||
->shouldReceive('delete')->withNoArgs()->once()->andReturn(1);
|
||||
|
||||
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
|
||||
$this->databaseRepository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
|
||||
$this->databaseRepository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
|
||||
->shouldReceive('findWhere')->with([
|
||||
['server_id', '=', $this->model->id],
|
||||
])->once()->andReturn(collect([(object) ['id' => 50]]));
|
||||
|
||||
$this->databaseManagementService->shouldReceive('delete')->with(50)->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('delete')->with($this->model->id)->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('delete')->with($this->model->id)->once()->andReturn(1);
|
||||
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
|
||||
$this->service->handle($this->model->id);
|
||||
|
|
Reference in a new issue