Fix existing tests

This commit is contained in:
Dane Everitt 2017-10-08 15:44:28 -05:00
parent 6e02e9491a
commit 159ad3079f
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
5 changed files with 40 additions and 51 deletions

View file

@ -13,6 +13,7 @@ use Exception;
use Mockery as m;
use Tests\TestCase;
use Pterodactyl\Models\Pack;
use Tests\Traits\MocksUuids;
use Illuminate\Http\UploadedFile;
use Illuminate\Contracts\Filesystem\Factory;
use Illuminate\Database\ConnectionInterface;
@ -23,18 +24,20 @@ use Pterodactyl\Exceptions\Service\Pack\InvalidFileMimeTypeException;
class PackCreationServiceTest extends TestCase
{
use MocksUuids;
/**
* @var \Illuminate\Database\ConnectionInterface
* @var \Illuminate\Database\ConnectionInterface|\Mockery\Mock
*/
protected $connection;
/**
* @var \Illuminate\Http\UploadedFile
* @var \Illuminate\Http\UploadedFile|\Mockery\Mock
*/
protected $file;
/**
* @var \Pterodactyl\Contracts\Repository\PackRepositoryInterface
* @var \Pterodactyl\Contracts\Repository\PackRepositoryInterface|\Mockery\Mock
*/
protected $repository;
@ -44,15 +47,10 @@ class PackCreationServiceTest extends TestCase
protected $service;
/**
* @var \Illuminate\Contracts\Filesystem\Factory
* @var \Illuminate\Contracts\Filesystem\Factory|\Mockery\Mock
*/
protected $storage;
/**
* @var \Ramsey\Uuid\Uuid
*/
protected $uuid;
/**
* Setup tests.
*/
@ -64,7 +62,6 @@ class PackCreationServiceTest extends TestCase
$this->file = m::mock(UploadedFile::class);
$this->repository = m::mock(PackRepositoryInterface::class);
$this->storage = m::mock(Factory::class);
$this->uuid = m::mock('overload:\Ramsey\Uuid\Uuid');
$this->service = new PackCreationService($this->connection, $this->storage, $this->repository);
}
@ -77,17 +74,15 @@ class PackCreationServiceTest extends TestCase
$model = factory(Pack::class)->make();
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
$this->uuid->shouldReceive('uuid4')->withNoArgs()->once()->andReturn($model->uuid);
$this->repository->shouldReceive('create')->with([
'uuid' => $model->uuid,
'uuid' => $this->getKnownUuid(),
'selectable' => false,
'visible' => false,
'locked' => false,
'test-data' => 'value',
])->once()->andReturn($model);
$this->storage->shouldReceive('disk')->withNoArgs()->once()->andReturnSelf()
->shouldReceive('makeDirectory')->with('packs/' . $model->uuid)->once()->andReturnNull();
$this->storage->shouldReceive('disk->makeDirectory')->with('packs/' . $model->uuid)->once()->andReturnNull();
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
$response = $this->service->handle(['test-data' => 'value']);
@ -107,17 +102,15 @@ class PackCreationServiceTest extends TestCase
$this->file->shouldReceive('isValid')->withNoArgs()->once()->andReturn(true);
$this->file->shouldReceive('getMimeType')->withNoArgs()->once()->andReturn($mime);
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
$this->uuid->shouldReceive('uuid4')->withNoArgs()->once()->andReturn($model->uuid);
$this->repository->shouldReceive('create')->with([
'uuid' => $model->uuid,
'uuid' => $this->getKnownUuid(),
'selectable' => false,
'visible' => false,
'locked' => false,
'test-data' => 'value',
])->once()->andReturn($model);
$this->storage->shouldReceive('disk')->withNoArgs()->once()->andReturnSelf()
->shouldReceive('makeDirectory')->with('packs/' . $model->uuid)->once()->andReturnNull();
$this->storage->shouldReceive('disk->makeDirectory')->with('packs/' . $model->uuid)->once()->andReturnNull();
$this->file->shouldReceive('storeAs')->with('packs/' . $model->uuid, 'archive.tar.gz')->once()->andReturnNull();
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();