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
|
@ -9,7 +9,6 @@
|
|||
|
||||
namespace Tests\Unit\Services\Services\Options;
|
||||
|
||||
use Exception;
|
||||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Models\Egg;
|
||||
|
|
|
@ -86,8 +86,8 @@ class EggUpdateImporterServiceTest extends TestCase
|
|||
'env_variable' => $variable->env_variable,
|
||||
], collect($variable)->except(['egg_id', 'env_variable'])->toArray())->once()->andReturnNull();
|
||||
|
||||
$this->variableRepository->shouldReceive('withColumns')->with(['id', 'env_variable'])->once()->andReturnSelf()
|
||||
->shouldReceive('findWhere')->with([['egg_id', '=', $egg->id]])->once()->andReturn([$variable]);
|
||||
$this->variableRepository->shouldReceive('setColumns')->with(['id', 'env_variable'])->once()->andReturnSelf()
|
||||
->shouldReceive('findWhere')->with([['egg_id', '=', $egg->id]])->once()->andReturn(collect([$variable]));
|
||||
|
||||
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
|
||||
|
@ -126,13 +126,13 @@ class EggUpdateImporterServiceTest extends TestCase
|
|||
'env_variable' => $variable1->env_variable,
|
||||
], collect($variable1)->except(['egg_id', 'env_variable'])->toArray())->once()->andReturnNull();
|
||||
|
||||
$this->variableRepository->shouldReceive('withColumns')->with(['id', 'env_variable'])->once()->andReturnSelf()
|
||||
->shouldReceive('findWhere')->with([['egg_id', '=', $egg->id]])->once()->andReturn([$variable1, $variable2]);
|
||||
$this->variableRepository->shouldReceive('setColumns')->with(['id', 'env_variable'])->once()->andReturnSelf()
|
||||
->shouldReceive('findWhere')->with([['egg_id', '=', $egg->id]])->once()->andReturn(collect([$variable1, $variable2]));
|
||||
|
||||
$this->variableRepository->shouldReceive('deleteWhere')->with([
|
||||
['egg_id', '=', $egg->id],
|
||||
['env_variable', '=', $variable2->env_variable],
|
||||
])->once()->andReturnNull();
|
||||
])->once()->andReturn(1);
|
||||
|
||||
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class VariableUpdateServiceTest extends TestCase
|
|||
*/
|
||||
public function testVariableIsUpdatedWhenValidEnvironmentVariableIsPassed()
|
||||
{
|
||||
$this->repository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
|
||||
$this->repository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
|
||||
->shouldReceive('findCountWhere')->with([
|
||||
['env_variable', '=', 'TEST_VAR_123'],
|
||||
['egg_id', '=', $this->model->option_id],
|
||||
|
@ -116,7 +116,7 @@ class VariableUpdateServiceTest extends TestCase
|
|||
*/
|
||||
public function testDataPassedIntoHandlerTakesLowerPriorityThanDataSet()
|
||||
{
|
||||
$this->repository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
|
||||
$this->repository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
|
||||
->shouldReceive('findCountWhere')->with([
|
||||
['env_variable', '=', 'TEST_VAR_123'],
|
||||
['egg_id', '=', $this->model->option_id],
|
||||
|
@ -138,7 +138,7 @@ class VariableUpdateServiceTest extends TestCase
|
|||
*/
|
||||
public function testExceptionIsThrownIfEnvironmentVariableIsNotUnique()
|
||||
{
|
||||
$this->repository->shouldReceive('withColumns')->with('id')->once()->andReturnSelf()
|
||||
$this->repository->shouldReceive('setColumns')->with('id')->once()->andReturnSelf()
|
||||
->shouldReceive('findCountWhere')->with([
|
||||
['env_variable', '=', 'TEST_VAR_123'],
|
||||
['egg_id', '=', $this->model->option_id],
|
||||
|
|
Reference in a new issue