Fix unit tests for eggs

This commit is contained in:
Dane Everitt 2020-10-05 21:29:35 -07:00
parent 0f4f2235a3
commit 0c2bd416ee
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
14 changed files with 130 additions and 200 deletions

View file

@ -1,11 +1,4 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Tests\Unit\Services\Eggs\Sharing;
@ -22,21 +15,11 @@ class EggExporterServiceTest extends TestCase
{
use NestedObjectAssertionsTrait;
/**
* @var \Carbon\Carbon
*/
protected $carbon;
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface|\Mockery\Mock
*/
protected $repository;
/**
* @var \Pterodactyl\Services\Eggs\Sharing\EggExporterService
*/
protected $service;
/**
* Setup tests.
*/
@ -45,10 +28,8 @@ class EggExporterServiceTest extends TestCase
parent::setUp();
Carbon::setTestNow(Carbon::now());
$this->carbon = new Carbon();
$this->repository = m::mock(EggRepositoryInterface::class);
$this->service = new EggExporterService($this->repository);
$this->repository = m::mock(EggRepositoryInterface::class);
}
/**
@ -56,12 +37,17 @@ class EggExporterServiceTest extends TestCase
*/
public function testJsonStructureIsExported()
{
$egg = factory(Egg::class)->make();
$egg = factory(Egg::class)->make([
'id' => 123,
'nest_id' => 456,
]);
$egg->variables = collect([$variable = factory(EggVariable::class)->make()]);
$this->repository->shouldReceive('getWithExportAttributes')->with($egg->id)->once()->andReturn($egg);
$response = $this->service->handle($egg->id);
$service = new EggExporterService($this->repository);
$response = $service->handle($egg->id);
$this->assertNotEmpty($response);
$data = json_decode($response);