Update a batch of failing tests

This commit is contained in:
Dane Everitt 2017-10-07 23:29:08 -05:00
parent c19c423568
commit 787346525b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
13 changed files with 218 additions and 195 deletions

View file

@ -30,34 +30,34 @@ class EggImporterService
*/
protected $eggVariableRepository;
/**
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
*/
protected $nestRepository;
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
*/
protected $repository;
/**
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
*/
protected $serviceRepository;
/**
* EggImporterService constructor.
*
* @param \Illuminate\Database\ConnectionInterface $connection
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $eggVariableRepository
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $serviceRepository
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $nestRepository
*/
public function __construct(
ConnectionInterface $connection,
EggRepositoryInterface $repository,
EggVariableRepositoryInterface $eggVariableRepository,
NestRepositoryInterface $serviceRepository
NestRepositoryInterface $nestRepository
) {
$this->connection = $connection;
$this->repository = $repository;
$this->serviceRepository = $serviceRepository;
$this->eggVariableRepository = $eggVariableRepository;
$this->repository = $repository;
$this->nestRepository = $nestRepository;
}
/**
@ -74,16 +74,16 @@ class EggImporterService
public function handle(UploadedFile $file, int $nest): Egg
{
if (! $file->isValid() || ! $file->isFile()) {
throw new InvalidFileUploadException(trans('exceptions.egg.importer.file_error'));
throw new InvalidFileUploadException(trans('exceptions.nest.importer.file_error'));
}
$parsed = json_decode($file->openFile()->fread($file->getSize()));
if (object_get($parsed, 'meta.version') !== 'PTDL_v1') {
throw new InvalidFileUploadException(trans('exceptions.egg.importer.invalid_json_provided'));
throw new InvalidFileUploadException(trans('exceptions.nest.importer.invalid_json_provided'));
}
$nest = $this->serviceRepository->getWithEggs($nest);
$nest = $this->nestRepository->getWithEggs($nest);
$this->connection->beginTransaction();
$egg = $this->repository->create([

View file

@ -10,34 +10,24 @@
namespace Pterodactyl\Services\Eggs\Variables;
use Pterodactyl\Models\EggVariable;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException;
class VariableCreationService
{
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
*/
protected $eggRepository;
/**
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
*/
protected $variableRepository;
protected $repository;
/**
* VariableCreationService constructor.
*
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $eggRepository
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $variableRepository
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $repository
*/
public function __construct(
EggRepositoryInterface $eggRepository,
EggVariableRepositoryInterface $variableRepository
) {
$this->eggRepository = $eggRepository;
$this->variableRepository = $variableRepository;
public function __construct(EggVariableRepositoryInterface $repository)
{
$this->repository = $repository;
}
/**
@ -61,10 +51,10 @@ class VariableCreationService
$options = array_get($data, 'options', []);
return $this->variableRepository->create(array_merge([
return $this->repository->create(array_merge($data, [
'egg_id' => $egg,
'user_viewable' => in_array('user_viewable', $options),
'user_editable' => in_array('user_editable', $options),
], $data));
]));
}
}

View file

@ -32,10 +32,8 @@ class NestCreationService
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
*/
public function __construct(
ConfigRepository $config,
NestRepositoryInterface $repository
) {
public function __construct(ConfigRepository $config, NestRepositoryInterface $repository)
{
$this->config = $config;
$this->repository = $repository;
}