update tests to use new factories

This commit is contained in:
Matthew Penner
2021-01-15 18:24:10 -07:00
parent 0330716174
commit ebc6efc5f4
58 changed files with 270 additions and 231 deletions

View File

@@ -2,6 +2,8 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
* @property int $node_id * @property int $node_id
@@ -21,6 +23,8 @@ namespace Pterodactyl\Models;
*/ */
class Allocation extends Model class Allocation extends Model
{ {
use HasFactory;
/** /**
* The resource name for this model when it is transformed into an * The resource name for this model when it is transformed into an
* API representation using fractal. * API representation using fractal.

View File

@@ -3,6 +3,7 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Pterodactyl\Services\Acl\Api\AdminAcl; use Pterodactyl\Services\Acl\Api\AdminAcl;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
@@ -18,6 +19,12 @@ use Pterodactyl\Services\Acl\Api\AdminAcl;
*/ */
class ApiKey extends Model class ApiKey extends Model
{ {
use HasFactory;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'api_key'; const RESOURCE_NAME = 'api_key';
/** /**

View File

@@ -2,6 +2,8 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
* @property int $server_id * @property int $server_id
@@ -19,6 +21,8 @@ namespace Pterodactyl\Models;
*/ */
class Database extends Model class Database extends Model
{ {
use HasFactory;
/** /**
* The resource name for this model when it is transformed into an * The resource name for this model when it is transformed into an
* API representation using fractal. * API representation using fractal.

View File

@@ -2,8 +2,12 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class DatabaseHost extends Model class DatabaseHost extends Model
{ {
use HasFactory;
/** /**
* The resource name for this model when it is transformed into an * The resource name for this model when it is transformed into an
* API representation using fractal. * API representation using fractal.

View File

@@ -2,6 +2,8 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
* @property string $uuid * @property string $uuid
@@ -46,6 +48,8 @@ namespace Pterodactyl\Models;
*/ */
class Egg extends Model class Egg extends Model
{ {
use HasFactory;
/** /**
* The resource name for this model when it is transformed into an * The resource name for this model when it is transformed into an
* API representation using fractal. * API representation using fractal.

View File

@@ -2,6 +2,8 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
* @property int $egg_id * @property int $egg_id
@@ -25,6 +27,8 @@ namespace Pterodactyl\Models;
*/ */
class EggVariable extends Model class EggVariable extends Model
{ {
use HasFactory;
/** /**
* The resource name for this model when it is transformed into an * The resource name for this model when it is transformed into an
* API representation using fractal. * API representation using fractal.

View File

@@ -2,6 +2,8 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
* @property string $short * @property string $short
@@ -14,6 +16,8 @@ namespace Pterodactyl\Models;
*/ */
class Location extends Model class Location extends Model
{ {
use HasFactory;
/** /**
* The resource name for this model when it is transformed into an * The resource name for this model when it is transformed into an
* API representation using fractal. * API representation using fractal.

View File

@@ -2,6 +2,8 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
* @property string $uuid * @property string $uuid
@@ -16,6 +18,8 @@ namespace Pterodactyl\Models;
*/ */
class Nest extends Model class Nest extends Model
{ {
use HasFactory;
/** /**
* The resource name for this model when it is transformed into an * The resource name for this model when it is transformed into an
* API representation using fractal. * API representation using fractal.

View File

@@ -6,6 +6,7 @@ use Symfony\Component\Yaml\Yaml;
use Illuminate\Container\Container; use Illuminate\Container\Container;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
@@ -38,6 +39,7 @@ use Illuminate\Contracts\Encryption\Encrypter;
*/ */
class Node extends Model class Node extends Model
{ {
use HasFactory;
use Notifiable; use Notifiable;
/** /**

View File

@@ -6,6 +6,7 @@ use Cron\CronExpression;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Illuminate\Container\Container; use Illuminate\Container\Container;
use Pterodactyl\Contracts\Extensions\HashidsInterface; use Pterodactyl\Contracts\Extensions\HashidsInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
@@ -29,6 +30,8 @@ use Pterodactyl\Contracts\Extensions\HashidsInterface;
*/ */
class Schedule extends Model class Schedule extends Model
{ {
use HasFactory;
/** /**
* The resource name for this model when it is transformed into an * The resource name for this model when it is transformed into an
* API representation using fractal. * API representation using fractal.

View File

@@ -5,6 +5,7 @@ namespace Pterodactyl\Models;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
use Znck\Eloquent\Traits\BelongsToThrough; use Znck\Eloquent\Traits\BelongsToThrough;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
@@ -54,6 +55,7 @@ use Znck\Eloquent\Traits\BelongsToThrough;
class Server extends Model class Server extends Model
{ {
use BelongsToThrough; use BelongsToThrough;
use HasFactory;
use Notifiable; use Notifiable;
/** /**

View File

@@ -3,6 +3,7 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
@@ -17,6 +18,7 @@ use Illuminate\Notifications\Notifiable;
*/ */
class Subuser extends Model class Subuser extends Model
{ {
use HasFactory;
use Notifiable; use Notifiable;
/** /**

View File

@@ -5,6 +5,7 @@ namespace Pterodactyl\Models;
use Illuminate\Container\Container; use Illuminate\Container\Container;
use Znck\Eloquent\Traits\BelongsToThrough; use Znck\Eloquent\Traits\BelongsToThrough;
use Pterodactyl\Contracts\Extensions\HashidsInterface; use Pterodactyl\Contracts\Extensions\HashidsInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/** /**
* @property int $id * @property int $id
@@ -25,6 +26,7 @@ use Pterodactyl\Contracts\Extensions\HashidsInterface;
class Task extends Model class Task extends Model
{ {
use BelongsToThrough; use BelongsToThrough;
use HasFactory;
/** /**
* The resource name for this model when it is transformed into an * The resource name for this model when it is transformed into an

View File

@@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Auth\Passwords\CanResetPassword;
use Pterodactyl\Traits\Helpers\AvailableLanguages; use Pterodactyl\Traits\Helpers\AvailableLanguages;
use Illuminate\Foundation\Auth\Access\Authorizable; use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
@@ -49,6 +50,7 @@ class User extends Model implements
use Authorizable; use Authorizable;
use AvailableLanguages; use AvailableLanguages;
use CanResetPassword; use CanResetPassword;
use HasFactory;
use Notifiable; use Notifiable;
const USER_LEVEL_USER = 0; const USER_LEVEL_USER = 0;

View File

@@ -23,7 +23,7 @@ class NodeFactory extends Factory
public function definition(): array public function definition(): array
{ {
return [ return [
'uuid' => Uuid::uuid4()->toString(), 'uuid' => $this->faker->unique()->uuid,
'public' => true, 'public' => true,
'name' => $this->faker->firstName, 'name' => $this->faker->firstName,
'fqdn' => $this->faker->ipv4, 'fqdn' => $this->faker->ipv4,

View File

@@ -26,7 +26,7 @@ class UserFactory extends Factory
return [ return [
'external_id' => $this->faker->unique()->isbn10, 'external_id' => $this->faker->unique()->isbn10,
'uuid' => $this->faker->uuid, 'uuid' => $this->faker->unique()->uuid,
'username' => $this->faker->userName, 'username' => $this->faker->userName,
'email' => $this->faker->safeEmail, 'email' => $this->faker->safeEmail,
'name_first' => $this->faker->firstName, 'name_first' => $this->faker->firstName,

View File

@@ -1,37 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="bootstrap/tests.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
backupStaticAttributes="false" <coverage processUncoveredFiles="true">
bootstrap="bootstrap/tests.php" <include>
colors="true" <directory suffix=".php">./app</directory>
convertErrorsToExceptions="true" </include>
convertNoticesToExceptions="true" </coverage>
convertWarningsToExceptions="true" <testsuites>
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer" <testsuite name="Browser">
processIsolation="false" <directory suffix="Test.php">./tests/Browser/Processes</directory>
stopOnFailure="false"> </testsuite>
<testsuites> <testsuite name="Integration">
<testsuite name="Browser"> <directory suffix="Test.php">./tests/Integration</directory>
<directory suffix="Test.php">./tests/Browser/Processes</directory> </testsuite>
</testsuite> <testsuite name="Unit">
<testsuite name="Integration"> <directory suffix="Test.php">./tests/Unit</directory>
<directory suffix="Test.php">./tests/Integration</directory> </testsuite>
</testsuite> </testsuites>
<testsuite name="Unit"> <php>
<directory suffix="Test.php">./tests/Unit</directory> <env name="APP_ENV" value="testing"/>
</testsuite> <env name="BCRYPT_ROUNDS" value="4"/>
</testsuites> <env name="DB_CONNECTION" value="testing"/>
<filter> <env name="CACHE_DRIVER" value="array"/>
<whitelist processUncoveredFilesFromWhitelist="true"> <env name="SESSION_DRIVER" value="array"/>
<directory suffix=".php">./app</directory> <env name="QUEUE_CONNECTION" value="sync"/>
</whitelist> <env name="MAIL_DRIVER" value="array"/>
</filter> </php>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="DB_CONNECTION" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="MAIL_DRIVER" value="array"/>
</php>
</phpunit> </phpunit>

View File

@@ -115,7 +115,7 @@ abstract class BrowserTestCase extends TestCase
*/ */
protected function user(array $attributes = []): User protected function user(array $attributes = []): User
{ {
return factory(User::class)->create(array_merge([ return User::factory()->create(array_merge([
'password' => Hash::make(static::$userPassword), 'password' => Hash::make(static::$userPassword),
], $attributes)); ], $attributes));
} }

View File

@@ -92,7 +92,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase
*/ */
protected function createApiUser(): User protected function createApiUser(): User
{ {
return factory(User::class)->create([ return User::factory()->create([
'root_admin' => true, 'root_admin' => true,
]); ]);
} }
@@ -106,7 +106,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase
*/ */
protected function createApiKey(User $user, array $permissions = []): ApiKey protected function createApiKey(User $user, array $permissions = []): ApiKey
{ {
return factory(ApiKey::class)->create(array_merge([ return ApiKey::factory()->create(array_merge([
'user_id' => $user->id, 'user_id' => $user->id,
'key_type' => ApiKey::TYPE_APPLICATION, 'key_type' => ApiKey::TYPE_APPLICATION,
'r_servers' => AdminAcl::READ | AdminAcl::WRITE, 'r_servers' => AdminAcl::READ | AdminAcl::WRITE,

View File

@@ -16,7 +16,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testGetLocations() public function testGetLocations()
{ {
$locations = factory(Location::class)->times(2)->create(); $locations = Location::factory()->times(2)->create();
$response = $this->getJson('/api/application/locations'); $response = $this->getJson('/api/application/locations');
$response->assertStatus(Response::HTTP_OK); $response->assertStatus(Response::HTTP_OK);
@@ -70,7 +70,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testGetSingleLocation() public function testGetSingleLocation()
{ {
$location = factory(Location::class)->create(); $location = Location::factory()->create();
$response = $this->getJson('/api/application/locations/' . $location->id); $response = $this->getJson('/api/application/locations/' . $location->id);
$response->assertStatus(Response::HTTP_OK); $response->assertStatus(Response::HTTP_OK);
@@ -93,7 +93,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testRelationshipsCanBeLoaded() public function testRelationshipsCanBeLoaded()
{ {
$location = factory(Location::class)->create(); $location = Location::factory()->create();
$server = $this->createServerModel(['user_id' => $this->getApiUser()->id, 'location_id' => $location->id]); $server = $this->createServerModel(['user_id' => $this->getApiUser()->id, 'location_id' => $location->id]);
$response = $this->getJson('/api/application/locations/' . $location->id . '?include=servers,nodes'); $response = $this->getJson('/api/application/locations/' . $location->id . '?include=servers,nodes');
@@ -143,8 +143,8 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
{ {
$this->createNewDefaultApiKey($this->getApiUser(), ['r_nodes' => 0]); $this->createNewDefaultApiKey($this->getApiUser(), ['r_nodes' => 0]);
$location = factory(Location::class)->create(); $location = Location::factory()->create();
factory(Node::class)->create(['location_id' => $location->id]); Node::factory()->create(['location_id' => $location->id]);
$response = $this->getJson('/api/application/locations/' . $location->id . '?include=nodes'); $response = $this->getJson('/api/application/locations/' . $location->id . '?include=nodes');
$response->assertStatus(Response::HTTP_OK); $response->assertStatus(Response::HTTP_OK);
@@ -187,7 +187,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testErrorReturnedIfNoPermission() public function testErrorReturnedIfNoPermission()
{ {
$location = factory(Location::class)->create(); $location = Location::factory()->create();
$this->createNewDefaultApiKey($this->getApiUser(), ['r_locations' => 0]); $this->createNewDefaultApiKey($this->getApiUser(), ['r_locations' => 0]);
$response = $this->getJson('/api/application/locations/' . $location->id); $response = $this->getJson('/api/application/locations/' . $location->id);

View File

@@ -13,7 +13,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testGetRemoteUser() public function testGetRemoteUser()
{ {
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->getJson('/api/application/users/external/' . $user->external_id); $response = $this->getJson('/api/application/users/external/' . $user->external_id);
$response->assertStatus(Response::HTTP_OK); $response->assertStatus(Response::HTTP_OK);
@@ -60,7 +60,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testErrorReturnedIfNoPermission() public function testErrorReturnedIfNoPermission()
{ {
$user = factory(User::class)->create(); $user = User::factory()->create();
$this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]);
$response = $this->getJson('/api/application/users/external/' . $user->external_id); $response = $this->getJson('/api/application/users/external/' . $user->external_id);

View File

@@ -16,7 +16,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testGetUsers() public function testGetUsers()
{ {
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->getJson('/api/application/users'); $response = $this->getJson('/api/application/users');
$response->assertStatus(Response::HTTP_OK); $response->assertStatus(Response::HTTP_OK);
@@ -85,7 +85,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testGetSingleUser() public function testGetSingleUser()
{ {
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->getJson('/api/application/users/' . $user->id); $response = $this->getJson('/api/application/users/' . $user->id);
$response->assertStatus(Response::HTTP_OK); $response->assertStatus(Response::HTTP_OK);
@@ -119,7 +119,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testRelationshipsCanBeLoaded() public function testRelationshipsCanBeLoaded()
{ {
$user = factory(User::class)->create(); $user = User::factory()->create();
$server = $this->createServerModel(['user_id' => $user->id]); $server = $this->createServerModel(['user_id' => $user->id]);
$response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers');
@@ -152,7 +152,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
{ {
$this->createNewDefaultApiKey($this->getApiUser(), ['r_servers' => 0]); $this->createNewDefaultApiKey($this->getApiUser(), ['r_servers' => 0]);
$user = factory(User::class)->create(); $user = User::factory()->create();
$this->createServerModel(['user_id' => $user->id]); $this->createServerModel(['user_id' => $user->id]);
$response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers');
@@ -194,7 +194,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testErrorReturnedIfNoPermission() public function testErrorReturnedIfNoPermission()
{ {
$user = factory(User::class)->create(); $user = User::factory()->create();
$this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]);
$response = $this->getJson('/api/application/users/' . $user->id); $response = $this->getJson('/api/application/users/' . $user->id);
@@ -250,7 +250,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testUpdateUser() public function testUpdateUser()
{ {
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->patchJson('/api/application/users/' . $user->id, [ $response = $this->patchJson('/api/application/users/' . $user->id, [
'username' => 'new.test.name', 'username' => 'new.test.name',
@@ -279,7 +279,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
*/ */
public function testDeleteUser() public function testDeleteUser()
{ {
$user = factory(User::class)->create(); $user = User::factory()->create();
$this->assertDatabaseHas('users', ['id' => $user->id]); $this->assertDatabaseHas('users', ['id' => $user->id]);
$response = $this->delete('/api/application/users/' . $user->id); $response = $this->delete('/api/application/users/' . $user->id);
@@ -302,7 +302,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
$this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => AdminAcl::READ]); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => AdminAcl::READ]);
if (str_contains($url, '{id}')) { if (str_contains($url, '{id}')) {
$user = factory(User::class)->create(); $user = User::factory()->create();
$url = str_replace('{id}', $user->id, $url); $url = str_replace('{id}', $user->id, $url);
} }

View File

@@ -15,7 +15,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
public function testAccountDetailsAreReturned() public function testAccountDetailsAreReturned()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->actingAs($user)->get('/api/client/account'); $response = $this->actingAs($user)->get('/api/client/account');
@@ -39,7 +39,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
public function testEmailIsUpdated() public function testEmailIsUpdated()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/email', [ $response = $this->actingAs($user)->putJson('/api/client/account/email', [
'email' => 'hodor@example.com', 'email' => 'hodor@example.com',
@@ -58,7 +58,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
public function testEmailIsNotUpdatedWhenPasswordIsInvalid() public function testEmailIsNotUpdatedWhenPasswordIsInvalid()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/email', [ $response = $this->actingAs($user)->putJson('/api/client/account/email', [
'email' => 'hodor@example.com', 'email' => 'hodor@example.com',
@@ -77,7 +77,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
public function testEmailIsNotUpdatedWhenNotValid() public function testEmailIsNotUpdatedWhenNotValid()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/email', [ $response = $this->actingAs($user)->putJson('/api/client/account/email', [
'email' => '', 'email' => '',
@@ -104,7 +104,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
public function testPasswordIsUpdated() public function testPasswordIsUpdated()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
$mock = Mockery::mock(AuthManager::class); $mock = Mockery::mock(AuthManager::class);
$mock->expects('logoutOtherDevices')->with('New_Password1'); $mock->expects('logoutOtherDevices')->with('New_Password1');
@@ -127,7 +127,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
public function testPasswordIsNotUpdatedIfCurrentPasswordIsInvalid() public function testPasswordIsNotUpdatedIfCurrentPasswordIsInvalid()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/password', [ $response = $this->actingAs($user)->putJson('/api/client/account/password', [
'current_password' => 'invalid', 'current_password' => 'invalid',
@@ -146,7 +146,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
*/ */
public function testErrorIsReturnedForInvalidRequestData() public function testErrorIsReturnedForInvalidRequestData()
{ {
$user = factory(User::class)->create(); $user = User::factory()->create();
$this->actingAs($user)->putJson('/api/client/account/password', [ $this->actingAs($user)->putJson('/api/client/account/password', [
'current_password' => 'password', 'current_password' => 'password',
@@ -170,7 +170,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
public function testErrorIsReturnedIfPasswordIsNotConfirmed() public function testErrorIsReturnedIfPasswordIsNotConfirmed()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/password', [ $response = $this->actingAs($user)->putJson('/api/client/account/password', [
'current_password' => 'password', 'current_password' => 'password',

View File

@@ -24,9 +24,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
public function testApiKeysAreReturned() public function testApiKeysAreReturned()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
/** @var \Pterodactyl\Models\ApiKey $key */ /** @var \Pterodactyl\Models\ApiKey $key */
$key = factory(ApiKey::class)->create([ $key = ApiKey::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'key_type' => ApiKey::TYPE_ACCOUNT, 'key_type' => ApiKey::TYPE_ACCOUNT,
]); ]);
@@ -59,13 +59,13 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
public function testApiKeyCanBeCreatedForAccount() public function testApiKeyCanBeCreatedForAccount()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
// Small sub-test to ensure we're always comparing the number of keys to the // Small sub-test to ensure we're always comparing the number of keys to the
// specific logged in account, and not just the total number of keys stored in // specific logged in account, and not just the total number of keys stored in
// the database. // the database.
factory(ApiKey::class)->times(10)->create([ ApiKey::factory()->times(10)->create([
'user_id' => factory(User::class)->create()->id, 'user_id' => User::factory()->create()->id,
'key_type' => ApiKey::TYPE_ACCOUNT, 'key_type' => ApiKey::TYPE_ACCOUNT,
]); ]);
@@ -103,8 +103,8 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
public function testNoMoreThanFiveApiKeysCanBeCreatedForAnAccount() public function testNoMoreThanFiveApiKeysCanBeCreatedForAnAccount()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
factory(ApiKey::class)->times(5)->create([ ApiKey::factory()->times(5)->create([
'user_id' => $user->id, 'user_id' => $user->id,
'key_type' => ApiKey::TYPE_ACCOUNT, 'key_type' => ApiKey::TYPE_ACCOUNT,
]); ]);
@@ -127,7 +127,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
public function testValidationErrorIsReturnedForBadRequests() public function testValidationErrorIsReturnedForBadRequests()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
$response = $this->actingAs($user)->postJson('/api/client/account/api-keys', [ $response = $this->actingAs($user)->postJson('/api/client/account/api-keys', [
'description' => '', 'description' => '',
@@ -154,9 +154,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
public function testApiKeyCanBeDeleted() public function testApiKeyCanBeDeleted()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
/** @var \Pterodactyl\Models\ApiKey $key */ /** @var \Pterodactyl\Models\ApiKey $key */
$key = factory(ApiKey::class)->create([ $key = ApiKey::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'key_type' => ApiKey::TYPE_ACCOUNT, 'key_type' => ApiKey::TYPE_ACCOUNT,
]); ]);
@@ -173,9 +173,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
public function testNonExistentApiKeyDeletionReturns404Error() public function testNonExistentApiKeyDeletionReturns404Error()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
/** @var \Pterodactyl\Models\ApiKey $key */ /** @var \Pterodactyl\Models\ApiKey $key */
$key = factory(ApiKey::class)->create([ $key = ApiKey::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'key_type' => ApiKey::TYPE_ACCOUNT, 'key_type' => ApiKey::TYPE_ACCOUNT,
]); ]);
@@ -193,11 +193,11 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
public function testApiKeyBelongingToAnotherUserCannotBeDeleted() public function testApiKeyBelongingToAnotherUserCannotBeDeleted()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
/** @var \Pterodactyl\Models\User $user2 */ /** @var \Pterodactyl\Models\User $user2 */
$user2 = factory(User::class)->create(); $user2 = User::factory()->create();
/** @var \Pterodactyl\Models\ApiKey $key */ /** @var \Pterodactyl\Models\ApiKey $key */
$key = factory(ApiKey::class)->create([ $key = ApiKey::factory()->create([
'user_id' => $user2->id, 'user_id' => $user2->id,
'key_type' => ApiKey::TYPE_ACCOUNT, 'key_type' => ApiKey::TYPE_ACCOUNT,
]); ]);
@@ -215,9 +215,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
public function testApplicationApiKeyCannotBeDeleted() public function testApplicationApiKeyCannotBeDeleted()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
/** @var \Pterodactyl\Models\ApiKey $key */ /** @var \Pterodactyl\Models\ApiKey $key */
$key = factory(ApiKey::class)->create([ $key = ApiKey::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'key_type' => ApiKey::TYPE_APPLICATION, 'key_type' => ApiKey::TYPE_APPLICATION,
]); ]);

View File

@@ -84,7 +84,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
protected function generateTestAccount(array $permissions = []): array protected function generateTestAccount(array $permissions = []): array
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
if (empty($permissions)) { if (empty($permissions)) {
return [$user, $this->createServerModel(['user_id' => $user->id])]; return [$user, $this->createServerModel(['user_id' => $user->id])];

View File

@@ -19,7 +19,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
public function testOnlyLoggedInUsersServersAreReturned() public function testOnlyLoggedInUsersServersAreReturned()
{ {
/** @var \Pterodactyl\Models\User[] $users */ /** @var \Pterodactyl\Models\User[] $users */
$users = factory(User::class)->times(3)->create(); $users = User::factory()->times(3)->create();
/** @var \Pterodactyl\Models\Server[] $servers */ /** @var \Pterodactyl\Models\Server[] $servers */
$servers = [ $servers = [
@@ -46,7 +46,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
public function testServersAreFilteredUsingNameAndUuidInformation() public function testServersAreFilteredUsingNameAndUuidInformation()
{ {
/** @var \Pterodactyl\Models\User[] $users */ /** @var \Pterodactyl\Models\User[] $users */
$users = factory(User::class)->times(2)->create(); $users = User::factory()->times(2)->create();
$users[0]->update(['root_admin' => true]); $users[0]->update(['root_admin' => true]);
/** @var \Pterodactyl\Models\Server[] $servers */ /** @var \Pterodactyl\Models\Server[] $servers */
@@ -106,8 +106,8 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
$server2 = $this->createServerModel(['user_id' => $user->id, 'node_id' => $server->node_id]); $server2 = $this->createServerModel(['user_id' => $user->id, 'node_id' => $server->node_id]);
$allocation = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id, 'ip' => '192.168.1.1', 'port' => 25565]); $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id, 'ip' => '192.168.1.1', 'port' => 25565]);
$allocation2 = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server2->id, 'ip' => '192.168.1.1', 'port' => 25570]); $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server2->id, 'ip' => '192.168.1.1', 'port' => 25570]);
$server->update(['allocation_id' => $allocation->id]); $server->update(['allocation_id' => $allocation->id]);
$server2->update(['allocation_id' => $allocation2->id]); $server2->update(['allocation_id' => $allocation2->id]);
@@ -144,7 +144,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
public function testServersUserIsASubuserOfAreReturned() public function testServersUserIsASubuserOfAreReturned()
{ {
/** @var \Pterodactyl\Models\User[] $users */ /** @var \Pterodactyl\Models\User[] $users */
$users = factory(User::class)->times(3)->create(); $users = User::factory()->times(3)->create();
$servers = [ $servers = [
$this->createServerModel(['user_id' => $users[0]->id]), $this->createServerModel(['user_id' => $users[0]->id]),
$this->createServerModel(['user_id' => $users[1]->id]), $this->createServerModel(['user_id' => $users[1]->id]),
@@ -175,7 +175,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
public function testFilterOnlyOwnerServers() public function testFilterOnlyOwnerServers()
{ {
/** @var \Pterodactyl\Models\User[] $users */ /** @var \Pterodactyl\Models\User[] $users */
$users = factory(User::class)->times(3)->create(); $users = User::factory()->times(3)->create();
$servers = [ $servers = [
$this->createServerModel(['user_id' => $users[0]->id]), $this->createServerModel(['user_id' => $users[0]->id]),
$this->createServerModel(['user_id' => $users[1]->id]), $this->createServerModel(['user_id' => $users[1]->id]),
@@ -204,7 +204,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
public function testPermissionsAreReturned() public function testPermissionsAreReturned()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
$this->actingAs($user) $this->actingAs($user)
->getJson('/api/client/permissions') ->getJson('/api/client/permissions')
@@ -224,7 +224,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
public function testOnlyAdminLevelServersAreReturned() public function testOnlyAdminLevelServersAreReturned()
{ {
/** @var \Pterodactyl\Models\User[] $users */ /** @var \Pterodactyl\Models\User[] $users */
$users = factory(User::class)->times(4)->create(); $users = User::factory()->times(4)->create();
$users[0]->update(['root_admin' => true]); $users[0]->update(['root_admin' => true]);
$servers = [ $servers = [
@@ -259,7 +259,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
public function testAllServersAreReturnedToAdmin() public function testAllServersAreReturnedToAdmin()
{ {
/** @var \Pterodactyl\Models\User[] $users */ /** @var \Pterodactyl\Models\User[] $users */
$users = factory(User::class)->times(4)->create(); $users = User::factory()->times(4)->create();
$users[0]->update(['root_admin' => true]); $users[0]->update(['root_admin' => true]);
$servers = [ $servers = [
@@ -292,7 +292,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser($type) public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser($type)
{ {
/** @var \Pterodactyl\Models\User[] $users */ /** @var \Pterodactyl\Models\User[] $users */
$users = factory(User::class)->times(3)->create(); $users = User::factory()->times(3)->create();
$this->createServerModel(['user_id' => $users[0]->id]); $this->createServerModel(['user_id' => $users[0]->id]);
$this->createServerModel(['user_id' => $users[1]->id]); $this->createServerModel(['user_id' => $users[1]->id]);
@@ -315,7 +315,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
$server->allocation->notes = 'Test notes'; $server->allocation->notes = 'Test notes';
$server->allocation->save(); $server->allocation->save();
factory(Allocation::class)->times(2)->create([ Allocation::factory()->times(2)->create([
'node_id' => $server->node_id, 'node_id' => $server->node_id,
'server_id' => $server->id, 'server_id' => $server->id,
]); ]);

View File

@@ -22,7 +22,7 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount($permission); [$user, $server] = $this->generateTestAccount($permission);
/** @var \Pterodactyl\Models\Allocation $allocation */ /** @var \Pterodactyl\Models\Allocation $allocation */
$allocation = factory(Allocation::class)->create([ $allocation = Allocation::factory()->create([
'server_id' => $server->id, 'server_id' => $server->id,
'node_id' => $server->node_id, 'node_id' => $server->node_id,
'notes' => 'hodor', 'notes' => 'hodor',
@@ -42,7 +42,7 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_CREATE]); [$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_CREATE]);
/** @var \Pterodactyl\Models\Allocation $allocation */ /** @var \Pterodactyl\Models\Allocation $allocation */
$allocation = factory(Allocation::class)->create([ $allocation = Allocation::factory()->create([
'server_id' => $server->id, 'server_id' => $server->id,
'node_id' => $server->node_id, 'node_id' => $server->node_id,
'notes' => 'hodor', 'notes' => 'hodor',

View File

@@ -32,7 +32,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
public function testServerAllocationsAreNotReturnedWithoutPermission() public function testServerAllocationsAreNotReturnedWithoutPermission()
{ {
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
$user2 = factory(User::class)->create(); $user2 = User::factory()->create();
$server->owner_id = $user2->id; $server->owner_id = $user2->id;
$server->save(); $server->save();
@@ -85,7 +85,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
public function testAllocationNotesCannotBeUpdatedByInvalidUsers() public function testAllocationNotesCannotBeUpdatedByInvalidUsers()
{ {
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
$user2 = factory(User::class)->create(); $user2 = User::factory()->create();
$server->owner_id = $user2->id; $server->owner_id = $user2->id;
$server->save(); $server->save();
@@ -105,7 +105,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
{ {
[$user, $server] = $this->generateTestAccount($permissions); [$user, $server] = $this->generateTestAccount($permissions);
$allocation = $server->allocation; $allocation = $server->allocation;
$allocation2 = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id]); $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
$server->allocation_id = $allocation->id; $server->allocation_id = $allocation->id;
$server->save(); $server->save();
@@ -121,7 +121,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
public function testPrimaryAllocationCannotBeModifiedByInvalidUser() public function testPrimaryAllocationCannotBeModifiedByInvalidUser()
{ {
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
$user2 = factory(User::class)->create(); $user2 = User::factory()->create();
$server->owner_id = $user2->id; $server->owner_id = $user2->id;
$server->save(); $server->save();

View File

@@ -20,8 +20,8 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
{ {
[$user, $server] = $this->generateTestAccount($permissions); [$user, $server] = $this->generateTestAccount($permissions);
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$task = factory(Task::class)->create(['schedule_id' => $schedule->id]); $task = Task::factory()->create(['schedule_id' => $schedule->id]);
$this->actingAs($user) $this->actingAs($user)
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") ->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
@@ -52,7 +52,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
[, $server2] = $this->generateTestAccount(['user_id' => $user->id]); [, $server2] = $this->generateTestAccount(['user_id' => $user->id]);
$schedule = factory(Schedule::class)->create(['server_id' => $server2->id]); $schedule = Schedule::factory()->create(['server_id' => $server2->id]);
$this->actingAs($user) $this->actingAs($user)
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") ->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
@@ -69,7 +69,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
{ {
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_UPDATE]); [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_UPDATE]);
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user) $this->actingAs($user)
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") ->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")

View File

@@ -25,7 +25,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
Bus::fake(); Bus::fake();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create([ $schedule = Schedule::factory()->create([
'server_id' => $server->id, 'server_id' => $server->id,
]); ]);
@@ -35,7 +35,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
$response->assertJsonPath('errors.0.detail', 'Cannot process schedule for task execution: no tasks are registered.'); $response->assertJsonPath('errors.0.detail', 'Cannot process schedule for task execution: no tasks are registered.');
/** @var \Pterodactyl\Models\Task $task */ /** @var \Pterodactyl\Models\Task $task */
$task = factory(Task::class)->create([ $task = Task::factory()->create([
'schedule_id' => $schedule->id, 'schedule_id' => $schedule->id,
'sequence_id' => 1, 'sequence_id' => 1,
'time_offset' => 2, 'time_offset' => 2,
@@ -60,7 +60,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create([ $schedule = Schedule::factory()->create([
'server_id' => $server->id, 'server_id' => $server->id,
'is_active' => false, 'is_active' => false,
]); ]);
@@ -80,7 +80,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]);
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden(); $this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden();
} }

View File

@@ -32,9 +32,9 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount($permissions); [$user, $server] = $this->generateTestAccount($permissions);
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
/** @var \Pterodactyl\Models\Task $task */ /** @var \Pterodactyl\Models\Task $task */
$task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 0]); $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 0]);
$response = $this->actingAs($user) $response = $this->actingAs($user)
->getJson( ->getJson(
@@ -66,7 +66,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
[, $server2] = $this->generateTestAccount(['user_id' => $user->id]); [, $server2] = $this->generateTestAccount(['user_id' => $user->id]);
$schedule = factory(Schedule::class)->create(['server_id' => $server2->id]); $schedule = Schedule::factory()->create(['server_id' => $server2->id]);
$this->actingAs($user) $this->actingAs($user)
->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") ->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
@@ -84,7 +84,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
->getJson("/api/client/servers/{$server->uuid}/schedules") ->getJson("/api/client/servers/{$server->uuid}/schedules")
->assertForbidden(); ->assertForbidden();
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user) $this->actingAs($user)
->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") ->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")

View File

@@ -34,7 +34,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount($permissions); [$user, $server] = $this->generateTestAccount($permissions);
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$expected = Utilities::getScheduleNextRunDate('5', '*', '*', '*'); $expected = Utilities::getScheduleNextRunDate('5', '*', '*', '*');
$response = $this->actingAs($user) $response = $this->actingAs($user)
@@ -59,7 +59,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
[, $server2] = $this->generateTestAccount(['user_id' => $user->id]); [, $server2] = $this->generateTestAccount(['user_id' => $user->id]);
$schedule = factory(Schedule::class)->create(['server_id' => $server2->id]); $schedule = Schedule::factory()->create(['server_id' => $server2->id]);
$this->actingAs($user) $this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
@@ -74,7 +74,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
{ {
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]);
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user) $this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
@@ -92,7 +92,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create([ $schedule = Schedule::factory()->create([
'server_id' => $server->id, 'server_id' => $server->id,
'is_active' => true, 'is_active' => true,
'is_processing' => true, 'is_processing' => true,

View File

@@ -21,7 +21,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount($permissions); [$user, $server] = $this->generateTestAccount($permissions);
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->assertEmpty($schedule->tasks); $this->assertEmpty($schedule->tasks);
$response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ $response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [
@@ -51,7 +51,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'))->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); $response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'))->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
@@ -96,7 +96,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [
'action' => 'backup', 'action' => 'backup',
@@ -121,8 +121,8 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
factory(Task::class)->times(2)->create(['schedule_id' => $schedule->id]); Task::factory()->times(2)->create(['schedule_id' => $schedule->id]);
$this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [
'action' => 'command', 'action' => 'command',
@@ -144,7 +144,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
[, $server2] = $this->generateTestAccount(['user_id' => $user->id]); [, $server2] = $this->generateTestAccount(['user_id' => $user->id]);
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server2->id]); $schedule = Schedule::factory()->create(['server_id' => $server2->id]);
$this->actingAs($user) $this->actingAs($user)
->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}/tasks") ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}/tasks")
@@ -160,7 +160,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]);
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user) $this->actingAs($user)
->postJson($this->link($schedule, '/tasks')) ->postJson($this->link($schedule, '/tasks'))

View File

@@ -19,8 +19,8 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase
$server2 = $this->createServerModel(); $server2 = $this->createServerModel();
[$user] = $this->generateTestAccount(); [$user] = $this->generateTestAccount();
$schedule = factory(Schedule::class)->create(['server_id' => $server2->id]); $schedule = Schedule::factory()->create(['server_id' => $server2->id]);
$task = factory(Task::class)->create(['schedule_id' => $schedule->id]); $task = Task::factory()->create(['schedule_id' => $schedule->id]);
$this->actingAs($user)->deleteJson($this->link($task))->assertNotFound(); $this->actingAs($user)->deleteJson($this->link($task))->assertNotFound();
} }
@@ -33,9 +33,9 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase
{ {
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$schedule2 = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule2 = Schedule::factory()->create(['server_id' => $server->id]);
$task = factory(Task::class)->create(['schedule_id' => $schedule->id]); $task = Task::factory()->create(['schedule_id' => $schedule->id]);
$this->actingAs($user)->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule2->id}/tasks/{$task->id}")->assertNotFound(); $this->actingAs($user)->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule2->id}/tasks/{$task->id}")->assertNotFound();
} }
@@ -47,12 +47,12 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase
{ {
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]);
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$task = factory(Task::class)->create(['schedule_id' => $schedule->id]); $task = Task::factory()->create(['schedule_id' => $schedule->id]);
$this->actingAs($user)->deleteJson($this->link($task))->assertForbidden(); $this->actingAs($user)->deleteJson($this->link($task))->assertForbidden();
$user2 = factory(User::class)->create(); $user2 = User::factory()->create();
$this->actingAs($user2)->deleteJson($this->link($task))->assertNotFound(); $this->actingAs($user2)->deleteJson($this->link($task))->assertNotFound();
} }
@@ -65,12 +65,12 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase
{ {
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$tasks = [ $tasks = [
factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]), Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]),
factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]), Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]),
factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]), Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]),
factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]), Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]),
]; ];
$response = $this->actingAs($user)->deleteJson($this->link($tasks[1])); $response = $this->actingAs($user)->deleteJson($this->link($tasks[1]));

View File

@@ -55,7 +55,7 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$this->actingAs($user)->getJson($this->link($server) . "/startup")->assertForbidden(); $this->actingAs($user)->getJson($this->link($server) . "/startup")->assertForbidden();
$user2 = factory(User::class)->create(); $user2 = User::factory()->create();
$this->actingAs($user2)->getJson($this->link($server) . "/startup")->assertNotFound(); $this->actingAs($user2)->getJson($this->link($server) . "/startup")->assertNotFound();
} }

View File

@@ -147,7 +147,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$this->actingAs($user)->putJson($this->link($server) . "/startup/variable")->assertForbidden(); $this->actingAs($user)->putJson($this->link($server) . "/startup/variable")->assertForbidden();
$user2 = factory(User::class)->create(); $user2 = User::factory()->create();
$this->actingAs($user2)->putJson($this->link($server) . "/startup/variable")->assertNotFound(); $this->actingAs($user2)->putJson($this->link($server) . "/startup/variable")->assertNotFound();
} }

View File

@@ -113,7 +113,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
/** @var \Pterodactyl\Models\User $existing */ /** @var \Pterodactyl\Models\User $existing */
$existing = factory(User::class)->create(['email' => $this->faker->email]); $existing = User::factory()->create(['email' => $this->faker->email]);
$response = $this->actingAs($user)->postJson($this->link($server) . "/users", [ $response = $this->actingAs($user)->postJson($this->link($server) . "/users", [
'email' => $existing->email, 'email' => $existing->email,

View File

@@ -30,13 +30,13 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
/** @var \Pterodactyl\Models\User $differentUser */ /** @var \Pterodactyl\Models\User $differentUser */
$differentUser = factory(User::class)->create(); $differentUser = User::factory()->create();
// Generate a UUID that lines up with a user in the database if it were to be cast to an int. // Generate a UUID that lines up with a user in the database if it were to be cast to an int.
$uuid = $differentUser->id . str_repeat('a', strlen((string)$differentUser->id)) . substr(Uuid::uuid4()->toString(), 8); $uuid = $differentUser->id . str_repeat('a', strlen((string)$differentUser->id)) . substr(Uuid::uuid4()->toString(), 8);
/** @var \Pterodactyl\Models\User $subuser */ /** @var \Pterodactyl\Models\User $subuser */
$subuser = factory(User::class)->create(['uuid' => $uuid]); $subuser = User::factory()->create(['uuid' => $uuid]);
Subuser::query()->forceCreate([ Subuser::query()->forceCreate([
'user_id' => $subuser->id, 'user_id' => $subuser->id,
@@ -52,7 +52,7 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
// anything in the database. // anything in the database.
$uuid = '18180000' . substr(Uuid::uuid4()->toString(), 8); $uuid = '18180000' . substr(Uuid::uuid4()->toString(), 8);
/** @var \Pterodactyl\Models\User $subuser */ /** @var \Pterodactyl\Models\User $subuser */
$subuser = factory(User::class)->create(['uuid' => $uuid]); $subuser = User::factory()->create(['uuid' => $uuid]);
Subuser::query()->forceCreate([ Subuser::query()->forceCreate([
'user_id' => $subuser->id, 'user_id' => $subuser->id,

View File

@@ -18,7 +18,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
public function testTwoFactorImageDataIsReturned() public function testTwoFactorImageDataIsReturned()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(['use_totp' => false]); $user = User::factory()->create(['use_totp' => false]);
$this->assertFalse($user->use_totp); $this->assertFalse($user->use_totp);
$this->assertEmpty($user->totp_secret); $this->assertEmpty($user->totp_secret);
@@ -42,7 +42,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
public function testErrorIsReturnedWhenTwoFactorIsAlreadyEnabled() public function testErrorIsReturnedWhenTwoFactorIsAlreadyEnabled()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(['use_totp' => true]); $user = User::factory()->create(['use_totp' => true]);
$response = $this->actingAs($user)->getJson('/api/client/account/two-factor'); $response = $this->actingAs($user)->getJson('/api/client/account/two-factor');
@@ -57,7 +57,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
public function testValidationErrorIsReturnedIfInvalidDataIsPassedToEnabled2FA() public function testValidationErrorIsReturnedIfInvalidDataIsPassedToEnabled2FA()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(['use_totp' => false]); $user = User::factory()->create(['use_totp' => false]);
$response = $this->actingAs($user)->postJson('/api/client/account/two-factor', [ $response = $this->actingAs($user)->postJson('/api/client/account/two-factor', [
'code' => '', 'code' => '',
@@ -74,7 +74,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
public function testTwoFactorCanBeEnabledOnAccount() public function testTwoFactorCanBeEnabledOnAccount()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(['use_totp' => false]); $user = User::factory()->create(['use_totp' => false]);
// Make the initial call to get the account setup for 2FA. // Make the initial call to get the account setup for 2FA.
$this->actingAs($user)->getJson('/api/client/account/two-factor')->assertOk(); $this->actingAs($user)->getJson('/api/client/account/two-factor')->assertOk();
@@ -126,7 +126,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
Carbon::setTestNow(Carbon::now()); Carbon::setTestNow(Carbon::now());
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(['use_totp' => true]); $user = User::factory()->create(['use_totp' => true]);
$response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [ $response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [
'password' => 'invalid', 'password' => 'invalid',
@@ -157,7 +157,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
Carbon::setTestNow(Carbon::now()); Carbon::setTestNow(Carbon::now());
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(['use_totp' => false]); $user = User::factory()->create(['use_totp' => false]);
$response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [ $response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [
'password' => 'password', 'password' => 'password',

View File

@@ -23,8 +23,8 @@ class UserControllerTest extends IntegrationTestCase
{ {
$unique = Str::random(16); $unique = Str::random(16);
$users = [ $users = [
factory(User::class)->create(['username' => $unique . '_1']), User::factory()->create(['username' => $unique . '_1']),
factory(User::class)->create(['username' => $unique . '_2']), User::factory()->create(['username' => $unique . '_2']),
]; ];
$servers = [ $servers = [

View File

@@ -32,7 +32,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$created = factory(Allocation::class)->create([ $created = Allocation::factory()->create([
'node_id' => $server->node_id, 'node_id' => $server->node_id,
'ip' => $server->allocation->ip, 'ip' => $server->allocation->ip,
]); ]);
@@ -74,7 +74,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
config()->set('pterodactyl.client_features.allocations.range_start', 5000); config()->set('pterodactyl.client_features.allocations.range_start', 5000);
config()->set('pterodactyl.client_features.allocations.range_end', 5001); config()->set('pterodactyl.client_features.allocations.range_end', 5001);
factory(Allocation::class)->create([ Allocation::factory()->create([
'server_id' => $server2->id, 'server_id' => $server2->id,
'node_id' => $server->node_id, 'node_id' => $server->node_id,
'ip' => $server->allocation->ip, 'ip' => $server->allocation->ip,
@@ -93,7 +93,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
config()->set('pterodactyl.client_features.allocations.range_end', 5005); config()->set('pterodactyl.client_features.allocations.range_end', 5005);
for ($i = 5000; $i <= 5005; $i++) { for ($i = 5000; $i <= 5005; $i++) {
factory(Allocation::class)->create([ Allocation::factory()->create([
'ip' => $server->allocation->ip, 'ip' => $server->allocation->ip,
'port' => $i, 'port' => $i,
'node_id' => $server->node_id, 'node_id' => $server->node_id,
@@ -115,7 +115,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
factory(Allocation::class)->times(5)->create(['node_id' => $server->node_id]); Allocation::factory()->times(5)->create(['node_id' => $server->node_id]);
$this->expectException(NoAutoAllocationSpaceAvailableException::class); $this->expectException(NoAutoAllocationSpaceAvailableException::class);
$this->expectExceptionMessage('Cannot assign additional allocation: no more space available on node.'); $this->expectExceptionMessage('Cannot assign additional allocation: no more space available on node.');

View File

@@ -63,9 +63,9 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
public function testDatabaseCannotBeCreatedIfServerHasReachedLimit() public function testDatabaseCannotBeCreatedIfServerHasReachedLimit()
{ {
$server = $this->createServerModel(['database_limit' => 2]); $server = $this->createServerModel(['database_limit' => 2]);
$host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
factory(Database::class)->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]); Database::factory()->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]);
$this->expectException(TooManyDatabasesException::class); $this->expectException(TooManyDatabasesException::class);
@@ -96,9 +96,9 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
$server = $this->createServerModel(); $server = $this->createServerModel();
$name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id);
$host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
$host2 = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); $host2 = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
factory(Database::class)->create([ Database::factory()->create([
'database' => $name, 'database' => $name,
'database_host_id' => $host->id, 'database_host_id' => $host->id,
'server_id' => $server->id, 'server_id' => $server->id,
@@ -125,7 +125,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
$server = $this->createServerModel(); $server = $this->createServerModel();
$name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id);
$host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
$this->repository->expects('createDatabase')->with($name); $this->repository->expects('createDatabase')->with($name);
@@ -183,7 +183,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
$server = $this->createServerModel(); $server = $this->createServerModel();
$name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id);
$host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
$this->repository->expects('createDatabase')->with($name)->andThrows(new BadMethodCallException); $this->repository->expects('createDatabase')->with($name)->andThrows(new BadMethodCallException);
$this->repository->expects('dropDatabase')->with($name); $this->repository->expects('dropDatabase')->with($name);

View File

@@ -65,8 +65,8 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$node = factory(Node::class)->create(['location_id' => $server->location->id]); $node = Node::factory()->create(['location_id' => $server->location->id]);
factory(DatabaseHost::class)->create(['node_id' => $node->id]); DatabaseHost::factory()->create(['node_id' => $node->id]);
config()->set('pterodactyl.client_features.databases.allow_random', false); config()->set('pterodactyl.client_features.databases.allow_random', false);
@@ -100,9 +100,9 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$node = factory(Node::class)->create(['location_id' => $server->location->id]); $node = Node::factory()->create(['location_id' => $server->location->id]);
factory(DatabaseHost::class)->create(['node_id' => $node->id]); DatabaseHost::factory()->create(['node_id' => $node->id]);
$host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]);
$this->managementService->expects('create')->with($server, [ $this->managementService->expects('create')->with($server, [
'database_host_id' => $host->id, 'database_host_id' => $host->id,
@@ -127,8 +127,8 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$node = factory(Node::class)->create(['location_id' => $server->location->id]); $node = Node::factory()->create(['location_id' => $server->location->id]);
$host = factory(DatabaseHost::class)->create(['node_id' => $node->id]); $host = DatabaseHost::factory()->create(['node_id' => $node->id]);
$this->managementService->expects('create')->with($server, [ $this->managementService->expects('create')->with($server, [
'database_host_id' => $host->id, 'database_host_id' => $host->id,

View File

@@ -71,24 +71,24 @@ class FindViableNodesServiceTest extends IntegrationTestCase
public function testExpectedNodeIsReturnedForLocation() public function testExpectedNodeIsReturnedForLocation()
{ {
/** @var \Pterodactyl\Models\Location[] $locations */ /** @var \Pterodactyl\Models\Location[] $locations */
$locations = factory(Location::class)->times(2)->create(); $locations = Location::factory()->times(2)->create();
/** @var \Pterodactyl\Models\Node[] $nodes */ /** @var \Pterodactyl\Models\Node[] $nodes */
$nodes = [ $nodes = [
// This node should never be returned once we've completed the initial test which // This node should never be returned once we've completed the initial test which
// runs without a location filter. // runs without a location filter.
factory(Node::class)->create([ Node::factory()->create([
'location_id' => $locations[0]->id, 'location_id' => $locations[0]->id,
'memory' => 2048, 'memory' => 2048,
'disk' => 1024 * 100, 'disk' => 1024 * 100,
]), ]),
factory(Node::class)->create([ Node::factory()->create([
'location_id' => $locations[1]->id, 'location_id' => $locations[1]->id,
'memory' => 1024, 'memory' => 1024,
'disk' => 10240, 'disk' => 10240,
'disk_overallocate' => 10, 'disk_overallocate' => 10,
]), ]),
factory(Node::class)->create([ Node::factory()->create([
'location_id' => $locations[1]->id, 'location_id' => $locations[1]->id,
'memory' => 1024 * 4, 'memory' => 1024 * 4,
'memory_overallocate' => 50, 'memory_overallocate' => 50,

View File

@@ -23,7 +23,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
public function testScheduleWithNoTasksReturnsException() public function testScheduleWithNoTasksReturnsException()
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->expectException(DisplayException::class); $this->expectException(DisplayException::class);
$this->expectExceptionMessage('Cannot process schedule for task execution: no tasks are registered.'); $this->expectExceptionMessage('Cannot process schedule for task execution: no tasks are registered.');
@@ -39,13 +39,13 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
$server = $this->createServerModel(); $server = $this->createServerModel();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create([ $schedule = Schedule::factory()->create([
'server_id' => $server->id, 'server_id' => $server->id,
'cron_minute' => 'hodor', // this will break the getNextRunDate() function. 'cron_minute' => 'hodor', // this will break the getNextRunDate() function.
]); ]);
/** @var \Pterodactyl\Models\Task $task */ /** @var \Pterodactyl\Models\Task $task */
$task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]);
$this->expectException(InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
@@ -68,10 +68,10 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
$server = $this->createServerModel(); $server = $this->createServerModel();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
/** @var \Pterodactyl\Models\Task $task */ /** @var \Pterodactyl\Models\Task $task */
$task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'time_offset' => 10, 'sequence_id' => 1]); $task = Task::factory()->create(['schedule_id' => $schedule->id, 'time_offset' => 10, 'sequence_id' => 1]);
$this->getService()->handle($schedule, $now); $this->getService()->handle($schedule, $now);
@@ -100,12 +100,12 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
$server = $this->createServerModel(); $server = $this->createServerModel();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id]); $schedule = Schedule::factory()->create(['server_id' => $server->id]);
/** @var \Pterodactyl\Models\Task $task */ /** @var \Pterodactyl\Models\Task $task */
$task2 = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]); $task2 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]);
$task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]); $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]);
$task3 = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]); $task3 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]);
$this->getService()->handle($schedule); $this->getService()->handle($schedule);
@@ -131,9 +131,9 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
$server = $this->createServerModel(); $server = $this->createServerModel();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
$schedule = factory(Schedule::class)->create(['server_id' => $server->id, 'last_run_at' => null]); $schedule = Schedule::factory()->create(['server_id' => $server->id, 'last_run_at' => null]);
/** @var \Pterodactyl\Models\Task $task */ /** @var \Pterodactyl\Models\Task $task */
$task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]);
$dispatcher->expects('dispatchNow')->andThrows(new Exception('Test thrown exception')); $dispatcher->expects('dispatchNow')->andThrows(new Exception('Test thrown exception'));

View File

@@ -36,7 +36,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
$server2 = $this->createServerModel(); $server2 = $this->createServerModel();
/** @var \Pterodactyl\Models\Allocation[] $allocations */ /** @var \Pterodactyl\Models\Allocation[] $allocations */
$allocations = factory(Allocation::class)->times(4)->create(['node_id' => $server->node_id, 'notes' => 'Random notes']); $allocations = Allocation::factory()->times(4)->create(['node_id' => $server->node_id, 'notes' => 'Random notes']);
$initialAllocationId = $server->allocation_id; $initialAllocationId = $server->allocation_id;
$allocations[0]->update(['server_id' => $server->id, 'notes' => 'Test notes']); $allocations[0]->update(['server_id' => $server->id, 'notes' => 'Test notes']);
@@ -83,7 +83,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
/** @var \Pterodactyl\Models\Allocation[] $allocations */ /** @var \Pterodactyl\Models\Allocation[] $allocations */
$allocations = factory(Allocation::class)->times(4)->create(['node_id' => $server->node_id]); $allocations = Allocation::factory()->times(4)->create(['node_id' => $server->node_id]);
$allocations[0]->update(['server_id' => $server->id]); $allocations[0]->update(['server_id' => $server->id]);
@@ -156,7 +156,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
/** @var \Pterodactyl\Models\Allocation[] $allocations */ /** @var \Pterodactyl\Models\Allocation[] $allocations */
$allocation = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id]); $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
$this->daemonServerRepository->expects('setServer->update')->andReturnUndefined(); $this->daemonServerRepository->expects('setServer->update')->andReturnUndefined();
@@ -179,7 +179,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
/** @var \Pterodactyl\Models\Allocation[] $allocations */ /** @var \Pterodactyl\Models\Allocation[] $allocations */
$allocation = factory(Allocation::class)->create(['node_id' => $server->node_id]); $allocation = Allocation::factory()->create(['node_id' => $server->node_id]);
$this->daemonServerRepository->expects('setServer->update')->andReturnUndefined(); $this->daemonServerRepository->expects('setServer->update')->andReturnUndefined();
@@ -198,8 +198,8 @@ class BuildModificationServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
/** @var \Pterodactyl\Models\Allocation[] $allocations */ /** @var \Pterodactyl\Models\Allocation[] $allocations */
$allocation = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id]); $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
$allocation2 = factory(Allocation::class)->create(['node_id' => $server->node_id]); $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id]);
$this->daemonServerRepository->expects('setServer->update')->andReturnUndefined(); $this->daemonServerRepository->expects('setServer->update')->andReturnUndefined();
@@ -220,7 +220,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
/** @var \Pterodactyl\Models\Allocation[] $allocations */ /** @var \Pterodactyl\Models\Allocation[] $allocations */
$allocation = factory(Allocation::class)->create(['node_id' => $server->node_id]); $allocation = Allocation::factory()->create(['node_id' => $server->node_id]);
$this->daemonServerRepository->expects('setServer->update')->andThrows(new DisplayException('Test')); $this->daemonServerRepository->expects('setServer->update')->andThrows(new DisplayException('Test'));

View File

@@ -48,15 +48,15 @@ class ServerCreationServiceTest extends IntegrationTestCase
public function testServerIsCreatedWithDeploymentObject() public function testServerIsCreatedWithDeploymentObject()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
/** @var \Pterodactyl\Models\Node $node */ /** @var \Pterodactyl\Models\Node $node */
$node = factory(Node::class)->create([ $node = Node::factory()->create([
'location_id' => factory(Location::class)->create()->id, 'location_id' => Location::factory()->create()->id,
]); ]);
/** @var \Pterodactyl\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations */ /** @var \Pterodactyl\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations */
$allocations = factory(Allocation::class)->times(5)->create([ $allocations = Allocation::factory()->times(5)->create([
'node_id' => $node->id, 'node_id' => $node->id,
]); ]);
@@ -156,15 +156,15 @@ class ServerCreationServiceTest extends IntegrationTestCase
public function testErrorEncounteredByWingsCausesServerToBeDeleted() public function testErrorEncounteredByWingsCausesServerToBeDeleted()
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = factory(User::class)->create(); $user = User::factory()->create();
/** @var \Pterodactyl\Models\Node $node */ /** @var \Pterodactyl\Models\Node $node */
$node = factory(Node::class)->create([ $node = Node::factory()->create([
'location_id' => factory(Location::class)->create()->id, 'location_id' => Location::factory()->create()->id,
]); ]);
/** @var \Pterodactyl\Models\Allocation $allocation */ /** @var \Pterodactyl\Models\Allocation $allocation */
$allocation = factory(Allocation::class)->create([ $allocation = Allocation::factory()->create([
'node_id' => $node->id, 'node_id' => $node->id,
]); ]);

View File

@@ -113,10 +113,10 @@ class ServerDeletionServiceTest extends IntegrationTestCase
public function testExceptionWhileDeletingStopsProcess() public function testExceptionWhileDeletingStopsProcess()
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$host = factory(DatabaseHost::class)->create(); $host = DatabaseHost::factory()->create();
/** @var \Pterodactyl\Models\Database $db */ /** @var \Pterodactyl\Models\Database $db */
$db = factory(Database::class)->create(['database_host_id' => $host->id, 'server_id' => $server->id]); $db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]);
$server->refresh(); $server->refresh();
@@ -138,10 +138,10 @@ class ServerDeletionServiceTest extends IntegrationTestCase
public function testExceptionWhileDeletingDatabasesDoesNotAbortIfForceDeleted() public function testExceptionWhileDeletingDatabasesDoesNotAbortIfForceDeleted()
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$host = factory(DatabaseHost::class)->create(); $host = DatabaseHost::factory()->create();
/** @var \Pterodactyl\Models\Database $db */ /** @var \Pterodactyl\Models\Database $db */
$db = factory(Database::class)->create(['database_host_id' => $host->id, 'server_id' => $server->id]); $db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]);
$server->refresh(); $server->refresh();

View File

@@ -50,7 +50,7 @@ trait RequestMockHelpers
*/ */
public function generateRequestUserModel(array $args = []): User public function generateRequestUserModel(array $args = []): User
{ {
$user = factory(User::class)->make($args); $user = User::factory()->make($args);
$this->setRequestUserModel($user); $this->setRequestUserModel($user);
return $user; return $user;
@@ -100,7 +100,7 @@ trait RequestMockHelpers
*/ */
protected function setRequestUser(User $user = null): User 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); $this->request->shouldReceive('user')->withNoArgs()->andReturn($user);
return $user; return $user;

View File

@@ -13,7 +13,7 @@ class AdminAuthenticateTest extends MiddlewareTestCase
*/ */
public function testAdminsAreAuthenticated() public function testAdminsAreAuthenticated()
{ {
$user = factory(User::class)->make(['root_admin' => 1]); $user = User::factory()->make(['root_admin' => 1]);
$this->request->shouldReceive('user')->withNoArgs()->twice()->andReturn($user); $this->request->shouldReceive('user')->withNoArgs()->twice()->andReturn($user);
@@ -39,7 +39,7 @@ class AdminAuthenticateTest extends MiddlewareTestCase
{ {
$this->expectException(AccessDeniedHttpException::class); $this->expectException(AccessDeniedHttpException::class);
$user = factory(User::class)->make(['root_admin' => 0]); $user = User::factory()->make(['root_admin' => 0]);
$this->request->shouldReceive('user')->withNoArgs()->twice()->andReturn($user); $this->request->shouldReceive('user')->withNoArgs()->twice()->andReturn($user);

View File

@@ -14,7 +14,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase
*/ */
public function testWithNoIPRestrictions() public function testWithNoIPRestrictions()
{ {
$model = factory(ApiKey::class)->make(['allowed_ips' => []]); $model = ApiKey::factory()->make(['allowed_ips' => []]);
$this->setRequestAttribute('api_key', $model); $this->setRequestAttribute('api_key', $model);
$this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions());
@@ -26,7 +26,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase
*/ */
public function testWithValidIP() public function testWithValidIP()
{ {
$model = factory(ApiKey::class)->make(['allowed_ips' => ['127.0.0.1']]); $model = ApiKey::factory()->make(['allowed_ips' => ['127.0.0.1']]);
$this->setRequestAttribute('api_key', $model); $this->setRequestAttribute('api_key', $model);
$this->request->shouldReceive('ip')->withNoArgs()->once()->andReturn('127.0.0.1'); $this->request->shouldReceive('ip')->withNoArgs()->once()->andReturn('127.0.0.1');
@@ -39,7 +39,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase
*/ */
public function testValidIPAgainstCIDRRange() public function testValidIPAgainstCIDRRange()
{ {
$model = factory(ApiKey::class)->make(['allowed_ips' => ['192.168.1.1/28']]); $model = ApiKey::factory()->make(['allowed_ips' => ['192.168.1.1/28']]);
$this->setRequestAttribute('api_key', $model); $this->setRequestAttribute('api_key', $model);
$this->request->shouldReceive('ip')->withNoArgs()->once()->andReturn('192.168.1.15'); $this->request->shouldReceive('ip')->withNoArgs()->once()->andReturn('192.168.1.15');
@@ -55,7 +55,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase
{ {
$this->expectException(AccessDeniedHttpException::class); $this->expectException(AccessDeniedHttpException::class);
$model = factory(ApiKey::class)->make(['allowed_ips' => ['127.0.0.1']]); $model = ApiKey::factory()->make(['allowed_ips' => ['127.0.0.1']]);
$this->setRequestAttribute('api_key', $model); $this->setRequestAttribute('api_key', $model);
$this->request->shouldReceive('ip')->withNoArgs()->twice()->andReturn('127.0.0.2'); $this->request->shouldReceive('ip')->withNoArgs()->twice()->andReturn('127.0.0.2');

View File

@@ -79,7 +79,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase
*/ */
public function testValidToken() public function testValidToken()
{ {
$model = factory(ApiKey::class)->make(); $model = ApiKey::factory()->make();
$this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'decrypted'); $this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'decrypted');
$this->repository->shouldReceive('findFirstWhere')->with([ $this->repository->shouldReceive('findFirstWhere')->with([
@@ -102,7 +102,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase
*/ */
public function testValidTokenWithUserKey() public function testValidTokenWithUserKey()
{ {
$model = factory(ApiKey::class)->make(); $model = ApiKey::factory()->make();
$this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'decrypted'); $this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'decrypted');
$this->repository->shouldReceive('findFirstWhere')->with([ $this->repository->shouldReceive('findFirstWhere')->with([
@@ -126,7 +126,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase
*/ */
public function testAccessWithoutToken() public function testAccessWithoutToken()
{ {
$user = factory(User::class)->make(['id' => 123]); $user = User::factory()->make(['id' => 123]);
$this->request->shouldReceive('user')->andReturn($user); $this->request->shouldReceive('user')->andReturn($user);
$this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturnNull(); $this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturnNull();
@@ -147,7 +147,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase
{ {
$this->expectException(AccessDeniedHttpException::class); $this->expectException(AccessDeniedHttpException::class);
$model = factory(ApiKey::class)->make(); $model = ApiKey::factory()->make();
$this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'asdf'); $this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'asdf');
$this->repository->shouldReceive('findFirstWhere')->with([ $this->repository->shouldReceive('findFirstWhere')->with([

View File

@@ -92,7 +92,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase
$this->expectException(AccessDeniedHttpException::class); $this->expectException(AccessDeniedHttpException::class);
/** @var \Pterodactyl\Models\Node $model */ /** @var \Pterodactyl\Models\Node $model */
$model = factory(Node::class)->make(); $model = Node::factory()->make();
$this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route');
$this->request->expects('bearerToken')->withNoArgs()->andReturn($model->daemon_token_id . '.random_string_123'); $this->request->expects('bearerToken')->withNoArgs()->andReturn($model->daemon_token_id . '.random_string_123');
@@ -125,7 +125,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase
public function testSuccessfulMiddlewareProcess() public function testSuccessfulMiddlewareProcess()
{ {
/** @var \Pterodactyl\Models\Node $model */ /** @var \Pterodactyl\Models\Node $model */
$model = factory(Node::class)->make(); $model = Node::factory()->make();
$this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route');
$this->request->expects('bearerToken')->withNoArgs()->andReturn($model->daemon_token_id . '.' . decrypt($model->daemon_token)); $this->request->expects('bearerToken')->withNoArgs()->andReturn($model->daemon_token_id . '.' . decrypt($model->daemon_token));

View File

@@ -40,7 +40,7 @@ class LanguageMiddlewareTest extends MiddlewareTestCase
*/ */
public function testLanguageIsSetWithAuthenticatedUser() public function testLanguageIsSetWithAuthenticatedUser()
{ {
$user = factory(User::class)->make(['language' => 'de']); $user = User::factory()->make(['language' => 'de']);
$this->request->shouldReceive('user')->withNoArgs()->andReturn($user); $this->request->shouldReceive('user')->withNoArgs()->andReturn($user);
$this->appMock->shouldReceive('setLocale')->with('de')->once()->andReturnNull(); $this->appMock->shouldReceive('setLocale')->with('de')->once()->andReturnNull();

View File

@@ -31,8 +31,8 @@ class MaintenanceMiddlewareTest extends MiddlewareTestCase
*/ */
public function testHandle() public function testHandle()
{ {
$server = factory(Server::class)->make(); $server = Server::factory()->make();
$node = factory(Node::class)->make(['maintenance' => 0]); $node = Node::factory()->make(['maintenance' => 0]);
$server->setRelation('node', $node); $server->setRelation('node', $node);
$this->setRequestAttribute('server', $server); $this->setRequestAttribute('server', $server);
@@ -45,8 +45,8 @@ class MaintenanceMiddlewareTest extends MiddlewareTestCase
*/ */
public function testHandleInMaintenanceMode() public function testHandleInMaintenanceMode()
{ {
$server = factory(Server::class)->make(); $server = Server::factory()->make();
$node = factory(Node::class)->make(['maintenance_mode' => 1]); $node = Node::factory()->make(['maintenance_mode' => 1]);
$server->setRelation('node', $node); $server->setRelation('node', $node);
$this->setRequestAttribute('server', $server); $this->setRequestAttribute('server', $server);

View File

@@ -49,7 +49,7 @@ class AccessingValidServerTest extends MiddlewareTestCase
$this->expectException(AccessDeniedHttpException::class); $this->expectException(AccessDeniedHttpException::class);
$this->expectExceptionMessage('Server is suspended and cannot be accessed.'); $this->expectExceptionMessage('Server is suspended and cannot be accessed.');
$model = factory(Server::class)->make(['suspended' => 1]); $model = Server::factory()->make(['suspended' => 1]);
$this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456'); $this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456');
$this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(true); $this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(true);
@@ -67,7 +67,7 @@ class AccessingValidServerTest extends MiddlewareTestCase
$this->expectException(ConflictHttpException::class); $this->expectException(ConflictHttpException::class);
$this->expectExceptionMessage('Server is still completing the installation process.'); $this->expectExceptionMessage('Server is still completing the installation process.');
$model = factory(Server::class)->make(['installed' => 0]); $model = Server::factory()->make(['installed' => 0]);
$this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456'); $this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456');
$this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(true); $this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(true);
@@ -101,7 +101,7 @@ class AccessingValidServerTest extends MiddlewareTestCase
*/ */
public function testValidServerProcess() public function testValidServerProcess()
{ {
$model = factory(Server::class)->make(); $model = Server::factory()->make();
$this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456'); $this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456');
$this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(false); $this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(false);
@@ -126,9 +126,9 @@ class AccessingValidServerTest extends MiddlewareTestCase
$this->refreshApplication(); $this->refreshApplication();
return [ return [
[factory(Server::class)->make(['suspended' => 1]), 'errors.suspended', 403], [Server::factory()->make(['suspended' => 1]), 'errors.suspended', 403],
[factory(Server::class)->make(['installed' => 0]), 'errors.installing', 409], [Server::factory()->make(['installed' => 0]), 'errors.installing', 409],
[factory(Server::class)->make(['installed' => 2]), 'errors.installing', 409], [Server::factory()->make(['installed' => 2]), 'errors.installing', 409],
]; ];
} }

View File

@@ -23,7 +23,7 @@ class AdminAclTest extends TestCase
*/ */
public function testCheck() public function testCheck()
{ {
$model = factory(ApiKey::class)->make(['r_servers' => AdminAcl::READ | AdminAcl::WRITE]); $model = ApiKey::factory()->make(['r_servers' => AdminAcl::READ | AdminAcl::WRITE]);
$this->assertTrue(AdminAcl::check($model, AdminAcl::RESOURCE_SERVERS, AdminAcl::WRITE)); $this->assertTrue(AdminAcl::check($model, AdminAcl::RESOURCE_SERVERS, AdminAcl::WRITE));
} }

View File

@@ -40,7 +40,7 @@ class KeyCreationServiceTest extends TestCase
*/ */
public function testKeyIsCreated() public function testKeyIsCreated()
{ {
$model = factory(ApiKey::class)->make(); $model = ApiKey::factory()->make();
$this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random') $this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random')
->expects($this->exactly(2))->willReturnCallback(function ($length) { ->expects($this->exactly(2))->willReturnCallback(function ($length) {
@@ -68,7 +68,7 @@ class KeyCreationServiceTest extends TestCase
*/ */
public function testIdentifierAndTokenAreOnlySetByFunction() public function testIdentifierAndTokenAreOnlySetByFunction()
{ {
$model = factory(ApiKey::class)->make(); $model = ApiKey::factory()->make();
$this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random') $this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random')
->expects($this->exactly(2))->willReturnCallback(function ($length) { ->expects($this->exactly(2))->willReturnCallback(function ($length) {
@@ -95,7 +95,7 @@ class KeyCreationServiceTest extends TestCase
*/ */
public function testPermissionsAreRetrievedForApplicationKeys() public function testPermissionsAreRetrievedForApplicationKeys()
{ {
$model = factory(ApiKey::class)->make(); $model = ApiKey::factory()->make();
$this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random') $this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random')
->expects($this->exactly(2))->willReturnCallback(function ($length) { ->expects($this->exactly(2))->willReturnCallback(function ($length) {
@@ -125,7 +125,7 @@ class KeyCreationServiceTest extends TestCase
*/ */
public function testPermissionsAreNotRetrievedForNonApplicationKeys($keyType) public function testPermissionsAreNotRetrievedForNonApplicationKeys($keyType)
{ {
$model = factory(ApiKey::class)->make(); $model = ApiKey::factory()->make();
$this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random') $this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random')
->expects($this->exactly(2))->willReturnCallback(function ($length) { ->expects($this->exactly(2))->willReturnCallback(function ($length) {