Update to Laravel 8
Co-authored-by: Matthew Penner <me@matthewp.io>
This commit is contained in:
parent
028921b42a
commit
a043071e3c
211 changed files with 4394 additions and 2933 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Traits\Http;
|
||||
namespace Pterodactyl\Tests\Traits\Http;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Testing\TestResponse;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Traits\Http;
|
||||
namespace Pterodactyl\Tests\Traits\Http;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Traits\Http;
|
||||
namespace Pterodactyl\Tests\Traits\Http;
|
||||
|
||||
use Mockery as m;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -50,7 +50,7 @@ trait RequestMockHelpers
|
|||
*/
|
||||
public function generateRequestUserModel(array $args = []): User
|
||||
{
|
||||
$user = factory(User::class)->make($args);
|
||||
$user = User::factory()->make($args);
|
||||
$this->setRequestUserModel($user);
|
||||
|
||||
return $user;
|
||||
|
@ -100,7 +100,7 @@ trait RequestMockHelpers
|
|||
*/
|
||||
protected function setRequestUser(User $user = null): User
|
||||
{
|
||||
$user = $user instanceof User ? $user : factory(User::class)->make();
|
||||
$user = $user instanceof User ? $user : User::factory()->make();
|
||||
$this->request->shouldReceive('user')->withNoArgs()->andReturn($user);
|
||||
|
||||
return $user;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Traits\Integration;
|
||||
namespace Pterodactyl\Tests\Traits\Integration;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Pterodactyl\Models\Egg;
|
||||
|
@ -10,7 +10,6 @@ use Pterodactyl\Models\User;
|
|||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
|
||||
|
||||
trait CreatesTestModels
|
||||
{
|
||||
|
@ -22,38 +21,41 @@ trait CreatesTestModels
|
|||
* The returned server model will have all of the relationships loaded onto it.
|
||||
*
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*/
|
||||
public function createServerModel(array $attributes = []): Server
|
||||
public function createServerModel(array $attributes = [])
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
$factory = $this->app->make(EloquentFactory::class);
|
||||
|
||||
if (isset($attributes['user_id'])) {
|
||||
$attributes['owner_id'] = $attributes['user_id'];
|
||||
}
|
||||
|
||||
if (! isset($attributes['owner_id'])) {
|
||||
$user = $factory->of(User::class)->create();
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = User::factory()->create();
|
||||
$attributes['owner_id'] = $user->id;
|
||||
}
|
||||
|
||||
if (! isset($attributes['node_id'])) {
|
||||
if (! isset($attributes['location_id'])) {
|
||||
$location = $factory->of(Location::class)->create();
|
||||
/** @var \Pterodactyl\Models\Location $location */
|
||||
$location = Location::factory()->create();
|
||||
$attributes['location_id'] = $location->id;
|
||||
}
|
||||
|
||||
$node = $factory->of(Node::class)->create(['location_id' => $attributes['location_id']]);
|
||||
/** @var \Pterodactyl\Models\Node $node */
|
||||
$node = Node::factory()->create(['location_id' => $attributes['location_id']]);
|
||||
$attributes['node_id'] = $node->id;
|
||||
}
|
||||
|
||||
if (! isset($attributes['allocation_id'])) {
|
||||
$allocation = $factory->of(Allocation::class)->create(['node_id' => $attributes['node_id']]);
|
||||
/** @var \Pterodactyl\Models\Allocation $allocation */
|
||||
$allocation = Allocation::factory()->create(['node_id' => $attributes['node_id']]);
|
||||
$attributes['allocation_id'] = $allocation->id;
|
||||
}
|
||||
|
||||
if (! isset($attributes['nest_id'])) {
|
||||
/** @var \Pterodactyl\Models\Nest $nest */
|
||||
$nest = Nest::with('eggs')->first();
|
||||
$attributes['nest_id'] = $nest->id;
|
||||
|
||||
|
@ -63,19 +65,21 @@ trait CreatesTestModels
|
|||
}
|
||||
|
||||
if (! isset($attributes['egg_id'])) {
|
||||
/** @var \Pterodactyl\Models\Egg $egg */
|
||||
$egg = Egg::where('nest_id', $attributes['nest_id'])->first();
|
||||
$attributes['egg_id'] = $egg->id;
|
||||
}
|
||||
|
||||
unset($attributes['user_id'], $attributes['location_id']);
|
||||
|
||||
$server = $factory->of(Server::class)->create($attributes);
|
||||
/** @var \Pterodactyl\Models\Server $server */
|
||||
$server = Server::factory()->create($attributes);
|
||||
|
||||
Allocation::query()->where('id', $server->allocation_id)->update(['server_id' => $server->id]);
|
||||
|
||||
return Server::with([
|
||||
return $server->fresh([
|
||||
'location', 'user', 'node', 'allocation', 'nest', 'egg',
|
||||
])->findOrFail($server->id);
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Traits;
|
||||
namespace Pterodactyl\Tests\Traits;
|
||||
|
||||
use PDO;
|
||||
use Mockery;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Traits;
|
||||
namespace Pterodactyl\Tests\Traits;
|
||||
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Tests\Traits;
|
||||
namespace Pterodactyl\Tests\Traits;
|
||||
|
||||
use Mockery as m;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue