Laravel 10 (#4706)

This commit is contained in:
Matthew Penner 2023-02-23 12:30:16 -07:00 committed by GitHub
parent ad4ddc6300
commit 1d38b4f0e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
136 changed files with 1735 additions and 2008 deletions

View file

@ -299,7 +299,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
* Endpoints that should return a 403 error when the key does not have write
* permissions for user management.
*/
public function userWriteEndpointsDataProvider(): array
public static function userWriteEndpointsDataProvider(): array
{
return [
['postJson', '/api/application/users'],

View file

@ -241,7 +241,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
* Provides some different IP address combinations that can be used when
* testing that we accept the expected IP values.
*/
public function validIPAddressDataProvider(): array
public static function validIPAddressDataProvider(): array
{
return [
[[]],

View file

@ -2,11 +2,9 @@
namespace Pterodactyl\Tests\Integration\Api\Client;
use ReflectionClass;
use Pterodactyl\Models\Node;
use Pterodactyl\Models\Task;
use Pterodactyl\Models\User;
use InvalidArgumentException;
use Pterodactyl\Models\Model;
use Pterodactyl\Models\Backup;
use Pterodactyl\Models\Server;
@ -75,7 +73,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
$link = "/api/client/servers/{$model->server->uuid}/backups/$model->uuid";
break;
default:
throw new InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model)));
throw new \InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model)));
}
return $link . ($append ? '/' . ltrim($append, '/') : '');
@ -87,7 +85,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
*/
protected function assertJsonTransformedWith(array $data, Model|EloquentModel $model)
{
$reflect = new ReflectionClass($model);
$reflect = new \ReflectionClass($model);
$transformer = sprintf('\\Pterodactyl\\Transformers\\Api\\Client\\%sTransformer', $reflect->getShortName());
$transformer = new $transformer();

View file

@ -331,7 +331,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
$response->assertJsonPath('data.0.attributes.relationships.allocations.data.0.attributes.notes', null);
}
public function filterTypeDataProvider(): array
public static function filterTypeDataProvider(): array
{
return [['admin'], ['admin-all']];
}

View file

@ -46,7 +46,7 @@ class AllocationAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound();
}
public function methodDataProvider(): array
public static function methodDataProvider(): array
{
return [
['POST', ''],

View file

@ -86,7 +86,7 @@ class CreateNewAllocationTest extends ClientApiIntegrationTestCase
->assertJsonPath('errors.0.detail', 'Cannot assign additional allocations to this server: limit has been reached.');
}
public function permissionDataProvider(): array
public static function permissionDataProvider(): array
{
return [[[Permission::ACTION_ALLOCATION_CREATE]], [[]]];
}

View file

@ -98,10 +98,7 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->deleteJson($this->link($server, "/network/allocations/{$server2->allocation_id}"))->assertNotFound();
}
/**
* @return array
*/
public function permissionDataProvider()
public static function permissionDataProvider(): array
{
return [[[Permission::ACTION_ALLOCATION_DELETE]], [[]]];
}

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Backup;
use Mockery;
use Carbon\CarbonImmutable;
use Pterodactyl\Models\Backup;
use Pterodactyl\Models\Subuser;
@ -31,7 +30,7 @@ class BackupAuthorizationTest extends ClientApiIntegrationTestCase
$backup2 = Backup::factory()->create(['server_id' => $server2->id, 'completed_at' => CarbonImmutable::now()]);
$backup3 = Backup::factory()->create(['server_id' => $server3->id, 'completed_at' => CarbonImmutable::now()]);
$this->instance(DeleteBackupService::class, $mock = Mockery::mock(DeleteBackupService::class));
$this->instance(DeleteBackupService::class, $mock = \Mockery::mock(DeleteBackupService::class));
if ($method === 'DELETE') {
$mock->expects('handle')->andReturnUndefined();
@ -55,7 +54,7 @@ class BackupAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound();
}
public function methodDataProvider(): array
public static function methodDataProvider(): array
{
return [
['GET', ''],

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Backup;
use Mockery;
use Mockery\MockInterface;
use Illuminate\Http\Response;
use Pterodactyl\Models\Backup;
@ -48,7 +47,7 @@ class DeleteBackupTest extends ClientApiIntegrationTestCase
$backup = Backup::factory()->create(['server_id' => $server->id]);
$this->repository->expects('setServer->delete')->with(
Mockery::on(function ($value) use ($backup) {
\Mockery::on(function ($value) use ($backup) {
return $value instanceof Backup && $value->uuid === $backup->uuid;
})
)->andReturn(new Response());

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server;
use Mockery;
use GuzzleHttp\Psr7\Request;
use Illuminate\Http\Response;
use Pterodactyl\Models\Server;
@ -55,7 +54,7 @@ class CommandControllerTest extends ClientApiIntegrationTestCase
$mock = $this->mock(DaemonCommandRepository::class);
$mock->expects('setServer')
->with(Mockery::on(fn (Server $value) => $value->is($server)))
->with(\Mockery::on(fn (Server $value) => $value->is($server)))
->andReturnSelf();
$mock->expects('send')->with('say Test')->andReturn(new GuzzleResponse());

View file

@ -58,7 +58,7 @@ class DatabaseAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $hashids->encode($database3->id) . $endpoint))->assertNotFound();
}
public function methodDataProvider(): array
public static function methodDataProvider(): array
{
return [
['POST', '/rotate-password'],

View file

@ -133,7 +133,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
->assertForbidden();
}
public function updatePermissionsDataProvider(): array
public static function updatePermissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_ALLOCATION_UPDATE]]];
}

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server;
use Mockery;
use Illuminate\Http\Response;
use Pterodactyl\Models\Permission;
use Pterodactyl\Repositories\Wings\DaemonPowerRepository;
@ -51,13 +50,13 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
*/
public function testActionCanBeSentToServer(string $action, string $permission)
{
$service = Mockery::mock(DaemonPowerRepository::class);
$service = \Mockery::mock(DaemonPowerRepository::class);
$this->app->instance(DaemonPowerRepository::class, $service);
[$user, $server] = $this->generateTestAccount([$permission]);
$service->expects('setServer')
->with(Mockery::on(function ($value) use ($server) {
->with(\Mockery::on(function ($value) use ($server) {
return $server->uuid === $value->uuid;
}))
->andReturnSelf()
@ -73,7 +72,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
/**
* Returns invalid permission combinations for a given power action.
*/
public function invalidPermissionDataProvider(): array
public static function invalidPermissionDataProvider(): array
{
return [
['start', [Permission::ACTION_CONTROL_STOP, Permission::ACTION_CONTROL_RESTART]],
@ -84,7 +83,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
];
}
public function validPowerActionDataProvider(): array
public static function validPowerActionDataProvider(): array
{
return [
['start', Permission::ACTION_CONTROL_START],

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server;
use Mockery;
use Pterodactyl\Models\Permission;
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
@ -14,12 +13,12 @@ class ResourceUtilizationControllerTest extends ClientApiIntegrationTestCase
*/
public function testServerResourceUtilizationIsReturned()
{
$service = Mockery::mock(DaemonServerRepository::class);
$service = \Mockery::mock(DaemonServerRepository::class);
$this->app->instance(DaemonServerRepository::class, $service);
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$service->expects('setServer')->with(Mockery::on(function ($value) use ($server) {
$service->expects('setServer')->with(\Mockery::on(function ($value) use ($server) {
return $server->uuid === $value->uuid;
}))->andReturnSelf()->getMock()->expects('getDetails')->andReturns([]);

View file

@ -89,7 +89,7 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase
->assertForbidden();
}
public function permissionsDataProvider(): array
public static function permissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_SCHEDULE_CREATE]]];
}

View file

@ -77,7 +77,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
$this->assertDatabaseHas('schedules', ['id' => $schedule->id]);
}
public function permissionsDataProvider(): array
public static function permissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_SCHEDULE_DELETE]]];
}

View file

@ -64,7 +64,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden();
}
public function permissionsDataProvider(): array
public static function permissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]];
}

View file

@ -89,7 +89,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
->assertForbidden();
}
public function permissionsDataProvider(): array
public static function permissionsDataProvider(): array
{
return [
[[], false],

View file

@ -54,7 +54,7 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound();
}
public function methodDataProvider(): array
public static function methodDataProvider(): array
{
return [
['GET', ''],

View file

@ -109,7 +109,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
$this->assertFalse($schedule->is_processing);
}
public function permissionsDataProvider(): array
public static function permissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]];
}

View file

@ -170,7 +170,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
->assertForbidden();
}
public function permissionsDataProvider(): array
public static function permissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]];
}

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server;
use Mockery;
use Illuminate\Http\Response;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Permission;
@ -78,11 +77,11 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount($permissions);
$this->assertTrue($server->isInstalled());
$service = Mockery::mock(DaemonServerRepository::class);
$service = \Mockery::mock(DaemonServerRepository::class);
$this->app->instance(DaemonServerRepository::class, $service);
$service->expects('setServer')
->with(Mockery::on(function ($value) use ($server) {
->with(\Mockery::on(function ($value) use ($server) {
return $value->uuid === $server->uuid;
}))
->andReturnSelf()
@ -113,12 +112,12 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
$this->assertTrue($server->isInstalled());
}
public function renamePermissionsDataProvider(): array
public static function renamePermissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_SETTINGS_RENAME]]];
}
public function reinstallPermissionsDataProvider(): array
public static function reinstallPermissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_SETTINGS_REINSTALL]]];
}

View file

@ -58,7 +58,7 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase
$this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound();
}
public function permissionsDataProvider(): array
public static function permissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_STARTUP_READ]]];
}

View file

@ -149,7 +149,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
$this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound();
}
public function permissionsDataProvider(): array
public static function permissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_STARTUP_UPDATE]]];
}

View file

@ -155,7 +155,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
$response->assertJsonPath('errors.0.detail', 'A user with that email address is already assigned as a subuser for this server.');
}
public function permissionsDataProvider(): array
public static function permissionsDataProvider(): array
{
return [[[]], [[Permission::ACTION_USER_CREATE]]];
}

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Subuser;
use Mockery;
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\User;
use Pterodactyl\Models\Subuser;
@ -25,7 +24,7 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
*/
public function testCorrectSubuserIsDeletedFromServer()
{
$this->swap(DaemonServerRepository::class, $mock = Mockery::mock(DaemonServerRepository::class));
$this->swap(DaemonServerRepository::class, $mock = \Mockery::mock(DaemonServerRepository::class));
[$user, $server] = $this->generateTestAccount();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Subuser;
use Mockery;
use Pterodactyl\Models\User;
use Pterodactyl\Models\Subuser;
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
@ -36,7 +35,7 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase
Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $internal->id]);
Subuser::factory()->create(['server_id' => $server3->id, 'user_id' => $internal->id]);
$this->instance(DaemonServerRepository::class, $mock = Mockery::mock(DaemonServerRepository::class));
$this->instance(DaemonServerRepository::class, $mock = \Mockery::mock(DaemonServerRepository::class));
if ($method === 'DELETE') {
$mock->expects('setServer->revokeUserJTI')->with($internal->id)->andReturnUndefined();
}
@ -50,7 +49,7 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/users/' . $internal->uuid))->assertNotFound();
}
public function methodDataProvider(): array
public static function methodDataProvider(): array
{
return [['GET'], ['POST'], ['DELETE']];
}

View file

@ -213,7 +213,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase
$this->post('/api/remote/sftp/auth', $data)->assertForbidden();
}
public function authorizationTypeDataProvider(): array
public static function authorizationTypeDataProvider(): array
{
return [
'password auth' => ['password'],
@ -221,7 +221,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase
];
}
public function serverStateDataProvider(): array
public static function serverStateDataProvider(): array
{
return [
'installing' => [Server::STATUS_INSTALLING],

View file

@ -2,14 +2,11 @@
namespace Pterodactyl\Tests\Integration\Jobs\Schedule;
use Mockery;
use Carbon\Carbon;
use DateTimeInterface;
use Carbon\CarbonImmutable;
use GuzzleHttp\Psr7\Request;
use Pterodactyl\Models\Task;
use GuzzleHttp\Psr7\Response;
use InvalidArgumentException;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Schedule;
use Illuminate\Support\Facades\Bus;
@ -40,7 +37,7 @@ class RunTaskJobTest extends IntegrationTestCase
$job = new RunTaskJob($task);
Bus::dispatchNow($job);
Bus::dispatchSync($job);
$task->refresh();
$schedule->refresh();
@ -48,7 +45,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing);
$this->assertFalse($schedule->is_active);
$this->assertTrue(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at));
$this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at));
}
public function testJobWithInvalidActionThrowsException()
@ -62,9 +59,9 @@ class RunTaskJobTest extends IntegrationTestCase
$job = new RunTaskJob($task);
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid task action provided: foobar');
Bus::dispatchNow($job);
Bus::dispatchSync($job);
}
/**
@ -90,22 +87,22 @@ class RunTaskJobTest extends IntegrationTestCase
'continue_on_failure' => false,
]);
$mock = Mockery::mock(DaemonPowerRepository::class);
$mock = \Mockery::mock(DaemonPowerRepository::class);
$this->instance(DaemonPowerRepository::class, $mock);
$mock->expects('setServer')->with(Mockery::on(function ($value) use ($server) {
$mock->expects('setServer')->with(\Mockery::on(function ($value) use ($server) {
return $value instanceof Server && $value->id === $server->id;
}))->andReturnSelf();
$mock->expects('send')->with('start')->andReturn(new Response());
Bus::dispatchNow(new RunTaskJob($task, $isManualRun));
Bus::dispatchSync(new RunTaskJob($task, $isManualRun));
$task->refresh();
$schedule->refresh();
$this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing);
$this->assertTrue(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at));
$this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at));
}
/**
@ -125,7 +122,7 @@ class RunTaskJobTest extends IntegrationTestCase
'continue_on_failure' => $continueOnFailure,
]);
$mock = Mockery::mock(DaemonPowerRepository::class);
$mock = \Mockery::mock(DaemonPowerRepository::class);
$this->instance(DaemonPowerRepository::class, $mock);
$mock->expects('setServer->send')->andThrow(
@ -136,7 +133,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->expectException(DaemonConnectionException::class);
}
Bus::dispatchNow(new RunTaskJob($task));
Bus::dispatchSync(new RunTaskJob($task));
if ($continueOnFailure) {
$task->refresh();
@ -144,7 +141,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing);
$this->assertTrue(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at));
$this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at));
}
}
@ -168,17 +165,17 @@ class RunTaskJobTest extends IntegrationTestCase
'payload' => 'start',
]);
Bus::dispatchNow(new RunTaskJob($task));
Bus::dispatchSync(new RunTaskJob($task));
$task->refresh();
$schedule->refresh();
$this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing);
$this->assertTrue(Carbon::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at));
$this->assertTrue(Carbon::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at));
}
public function isManualRunDataProvider(): array
public static function isManualRunDataProvider(): array
{
return [[true], [false]];
}

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Tests\Integration\Services\Allocations;
use Exception;
use InvalidArgumentException;
use Pterodactyl\Models\Allocation;
use Pterodactyl\Tests\Integration\IntegrationTestCase;
use Pterodactyl\Services\Allocations\FindAssignableAllocationService;
@ -142,8 +140,8 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
try {
$this->getService()->handle($server);
$this->fail('This assertion should not be reached.');
} catch (Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception);
} catch (\Exception $exception) {
$this->assertInstanceOf(\InvalidArgumentException::class, $exception);
$this->assertSame('Expected an integerish value. Got: string', $exception->getMessage());
}
@ -153,8 +151,8 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
try {
$this->getService()->handle($server);
$this->fail('This assertion should not be reached.');
} catch (Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception);
} catch (\Exception $exception) {
$this->assertInstanceOf(\InvalidArgumentException::class, $exception);
$this->assertSame('Expected an integerish value. Got: string', $exception->getMessage());
}
}

View file

@ -2,10 +2,7 @@
namespace Pterodactyl\Tests\Integration\Services\Databases;
use Mockery;
use Mockery\MockInterface;
use BadMethodCallException;
use InvalidArgumentException;
use Pterodactyl\Models\Database;
use Pterodactyl\Models\DatabaseHost;
use Pterodactyl\Tests\Integration\IntegrationTestCase;
@ -79,7 +76,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
{
$server = $this->createServerModel();
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The database name passed to DatabaseManagementService::handle MUST be prefixed with "s{server_id}_".');
$this->getService()->create($server, $data);
@ -134,13 +131,13 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
// assertions that would get caught by the functions catcher and thus lead to the exception
// being swallowed incorrectly.
$this->repository->expects('createUser')->with(
Mockery::on(function ($value) use (&$username) {
\Mockery::on(function ($value) use (&$username) {
$username = $value;
return true;
}),
'%',
Mockery::on(function ($value) use (&$password) {
\Mockery::on(function ($value) use (&$password) {
$password = $value;
return true;
@ -148,7 +145,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
null
);
$this->repository->expects('assignUserToDatabase')->with($name, Mockery::on(function ($value) use (&$secondUsername) {
$this->repository->expects('assignUserToDatabase')->with($name, \Mockery::on(function ($value) use (&$secondUsername) {
$secondUsername = $value;
return true;
@ -182,11 +179,11 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
$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('dropUser')->withAnyArgs()->andThrows(new InvalidArgumentException());
$this->repository->expects('dropUser')->withAnyArgs()->andThrows(new \InvalidArgumentException());
$this->expectException(BadMethodCallException::class);
$this->expectException(\BadMethodCallException::class);
$this->getService()->create($server, [
'remote' => '%',
@ -197,7 +194,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
$this->assertDatabaseMissing('databases', ['server_id' => $server->id]);
}
public function invalidDataDataProvider(): array
public static function invalidDataDataProvider(): array
{
return [
[[]],

View file

@ -2,10 +2,8 @@
namespace Pterodactyl\Tests\Integration\Services\Databases;
use Mockery;
use Mockery\MockInterface;
use Pterodactyl\Models\Node;
use InvalidArgumentException;
use Pterodactyl\Models\Database;
use Pterodactyl\Models\DatabaseHost;
use Pterodactyl\Tests\Integration\IntegrationTestCase;
@ -24,7 +22,7 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
{
parent::setUp();
$this->managementService = Mockery::mock(DatabaseManagementService::class);
$this->managementService = \Mockery::mock(DatabaseManagementService::class);
$this->swap(DatabaseManagementService::class, $this->managementService);
}
@ -50,7 +48,7 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
{
$server = $this->createServerModel();
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/^Expected a non-empty value\. Got: /');
$this->getService()->handle($server, $data);
}
@ -142,7 +140,7 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
$this->assertInstanceOf(Database::class, $response);
}
public function invalidDataProvider(): array
public static function invalidDataProvider(): array
{
return [
[['remote' => '%']],

View file

@ -2,9 +2,7 @@
namespace Pterodactyl\Tests\Integration\Services\Deployment;
use Exception;
use Pterodactyl\Models\Node;
use InvalidArgumentException;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Database;
use Pterodactyl\Models\Location;
@ -26,7 +24,7 @@ class FindViableNodesServiceTest extends IntegrationTestCase
public function testExceptionIsThrownIfNoDiskSpaceHasBeenSet()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Disk space must be an int, got NULL');
$this->getService()->handle();
@ -34,7 +32,7 @@ class FindViableNodesServiceTest extends IntegrationTestCase
public function testExceptionIsThrownIfNoMemoryHasBeenSet()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Memory usage must be an int, got NULL');
$this->getService()->setDisk(10)->handle();
@ -54,16 +52,16 @@ class FindViableNodesServiceTest extends IntegrationTestCase
try {
$this->getService()->setLocations(['a']);
$this->fail('This expectation should not be called.');
} catch (Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception);
} catch (\Exception $exception) {
$this->assertInstanceOf(\InvalidArgumentException::class, $exception);
$this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage());
}
try {
$this->getService()->setLocations(['1.2', '1', 2]);
$this->fail('This expectation should not be called.');
} catch (Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception);
} catch (\Exception $exception) {
$this->assertInstanceOf(\InvalidArgumentException::class, $exception);
$this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage());
}
}

View file

@ -2,11 +2,9 @@
namespace Pterodactyl\Tests\Integration\Services\Schedules;
use Mockery;
use Exception;
use Carbon\CarbonImmutable;
use Pterodactyl\Models\Task;
use InvalidArgumentException;
use Pterodactyl\Models\Schedule;
use Illuminate\Support\Facades\Bus;
use Illuminate\Contracts\Bus\Dispatcher;
@ -47,7 +45,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
/** @var \Pterodactyl\Models\Task $task */
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]);
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->getService()->handle($schedule);
@ -126,7 +124,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
*/
public function testTaskDispatchedNowIsResetProperlyIfErrorIsEncountered()
{
$this->swap(Dispatcher::class, $dispatcher = Mockery::mock(Dispatcher::class));
$this->swap(Dispatcher::class, $dispatcher = \Mockery::mock(Dispatcher::class));
$server = $this->createServerModel();
/** @var \Pterodactyl\Models\Schedule $schedule */
@ -134,9 +132,9 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
/** @var \Pterodactyl\Models\Task $task */
$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'));
$this->expectException(Exception::class);
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Test thrown exception');
$this->getService()->handle($schedule, true);
@ -150,7 +148,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
$this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => false]);
}
public function dispatchNowDataProvider(): array
public static function dispatchNowDataProvider(): array
{
return [[true], [false]];
}

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Mockery\MockInterface;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
@ -108,7 +107,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
{
$server = $this->createServerModel();
$this->daemonServerRepository->expects('setServer')->with(Mockery::on(function (Server $s) use ($server) {
$this->daemonServerRepository->expects('setServer')->with(\Mockery::on(function (Server $s) use ($server) {
return $s->id === $server->id;
}))->andReturnSelf();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Mockery\MockInterface;
use Pterodactyl\Models\Egg;
use GuzzleHttp\Psr7\Request;
@ -42,7 +41,7 @@ class ServerCreationServiceTest extends IntegrationTestCase
->where('name', 'Bungeecord')
->firstOrFail();
$this->daemonServerRepository = Mockery::mock(DaemonServerRepository::class);
$this->daemonServerRepository = \Mockery::mock(DaemonServerRepository::class);
$this->swap(DaemonServerRepository::class, $this->daemonServerRepository);
}

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Exception;
use Mockery\MockInterface;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
@ -35,8 +33,8 @@ class ServerDeletionServiceTest extends IntegrationTestCase
// There will be some log calls during this test, don't actually write to the disk.
config()->set('logging.default', 'null');
$this->daemonServerRepository = Mockery::mock(DaemonServerRepository::class);
$this->databaseManagementService = Mockery::mock(DatabaseManagementService::class);
$this->daemonServerRepository = \Mockery::mock(DaemonServerRepository::class);
$this->databaseManagementService = \Mockery::mock(DatabaseManagementService::class);
$this->app->instance(DaemonServerRepository::class, $this->daemonServerRepository);
$this->app->instance(DatabaseManagementService::class, $this->databaseManagementService);
@ -120,11 +118,11 @@ class ServerDeletionServiceTest extends IntegrationTestCase
$server->refresh();
$this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andReturnUndefined();
$this->databaseManagementService->expects('delete')->with(Mockery::on(function ($value) use ($db) {
$this->databaseManagementService->expects('delete')->with(\Mockery::on(function ($value) use ($db) {
return $value instanceof Database && $value->id === $db->id;
}))->andThrows(new Exception());
}))->andThrows(new \Exception());
$this->expectException(Exception::class);
$this->expectException(\Exception::class);
$this->getService()->handle($server);
$this->assertDatabaseHas('servers', ['id' => $server->id]);
@ -145,9 +143,9 @@ class ServerDeletionServiceTest extends IntegrationTestCase
$server->refresh();
$this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andReturnUndefined();
$this->databaseManagementService->expects('delete')->with(Mockery::on(function ($value) use ($db) {
$this->databaseManagementService->expects('delete')->with(\Mockery::on(function ($value) use ($db) {
return $value instanceof Database && $value->id === $db->id;
}))->andThrows(new Exception());
}))->andThrows(new \Exception());
$this->getService()->withForce(true)->handle($server);

View file

@ -34,7 +34,7 @@ class StartupModificationServiceTest extends IntegrationTestCase
]);
$this->fail('This assertion should not be called.');
} catch (Exception $exception) {
} catch (\Exception $exception) {
$this->assertInstanceOf(ValidationException::class, $exception);
/** @var \Illuminate\Validation\ValidationException $exception */

View file

@ -2,9 +2,7 @@
namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Mockery\MockInterface;
use InvalidArgumentException;
use Pterodactyl\Models\Server;
use Pterodactyl\Services\Servers\SuspensionService;
use Pterodactyl\Tests\Integration\IntegrationTestCase;
@ -21,7 +19,7 @@ class SuspensionServiceTest extends IntegrationTestCase
{
parent::setUp();
$this->repository = Mockery::mock(DaemonServerRepository::class);
$this->repository = \Mockery::mock(DaemonServerRepository::class);
$this->app->instance(DaemonServerRepository::class, $this->repository);
}
@ -60,7 +58,7 @@ class SuspensionServiceTest extends IntegrationTestCase
{
$server = $this->createServerModel();
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Expected one of: "suspend", "unsuspend". Got: "foo"');
$this->getService()->toggle($server, 'foo');

View file

@ -4,7 +4,6 @@ namespace Pterodactyl\Tests\Traits\Http;
use Closure;
use Illuminate\Http\Request;
use BadFunctionCallException;
trait MocksMiddlewareClosure
{
@ -12,10 +11,10 @@ trait MocksMiddlewareClosure
* Provide a closure to be used when validating that the response from the middleware
* is the same request object we passed into it.
*/
protected function getClosureAssertions(): Closure
protected function getClosureAssertions(): \Closure
{
if (is_null($this->request)) {
throw new BadFunctionCallException('Calling getClosureAssertions without defining a request object is not supported.');
throw new \BadFunctionCallException('Calling getClosureAssertions without defining a request object is not supported.');
}
return function ($response) {

View file

@ -6,7 +6,6 @@ use Mockery as m;
use Mockery\Mock;
use Illuminate\Http\Request;
use Pterodactyl\Models\User;
use InvalidArgumentException;
use Symfony\Component\HttpFoundation\ParameterBag;
trait RequestMockHelpers
@ -68,7 +67,7 @@ trait RequestMockHelpers
{
$this->request = m::mock($this->requestMockClass);
if (!$this->request instanceof Request) {
throw new InvalidArgumentException('Request mock class must be an instance of ' . Request::class . ' when mocked.');
throw new \InvalidArgumentException('Request mock class must be an instance of ' . Request::class . ' when mocked.');
}
$this->request->attributes = new ParameterBag();

View file

@ -23,7 +23,7 @@ trait MocksPdoConnection
Model::unsetConnectionResolver();
$connection = new MySqlConnection($mock = Mockery::mock(PDO::class), 'testing_mock');
$connection = new MySqlConnection($mock = \Mockery::mock(\PDO::class), 'testing_mock');
$resolver = new ConnectionResolver(['mocked' => $connection]);
$resolver->setDefaultConnection('mocked');

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Traits;
use Mockery;
use Mockery\Mock;
use Mockery\MockInterface;
use GuzzleHttp\Exception\RequestException;
@ -27,6 +26,6 @@ trait MocksRequestException
*/
protected function getExceptionMock(string $abstract = RequestException::class): MockInterface
{
return $this->exception ?? $this->exception = Mockery::mock($abstract);
return $this->exception ?? $this->exception = \Mockery::mock($abstract);
}
}

View file

@ -17,7 +17,7 @@ class EnvironmentWriterTraitTest extends TestCase
$this->assertSame($expected, $output);
}
public function variableDataProvider(): array
public static function variableDataProvider(): array
{
return [
['foo', 'foo'],

View file

@ -19,7 +19,7 @@ class IsDigitTest extends TestCase
/**
* Provide data to test against the helper function.
*/
public function helperDataProvider(): array
public static function helperDataProvider(): array
{
return [
[true, false],

View file

@ -138,7 +138,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase
*
* @return array|\string[][]
*/
public function badTokenDataProvider(): array
public static function badTokenDataProvider(): array
{
return [
['foo'],

View file

@ -38,7 +38,7 @@ class UsernameTest extends TestCase
/**
* Provide valid usernames.
*/
public function validUsernameDataProvider(): array
public static function validUsernameDataProvider(): array
{
return [
['username'],
@ -54,7 +54,7 @@ class UsernameTest extends TestCase
/**
* Provide invalid usernames.
*/
public function invalidUsernameDataProvider(): array
public static function invalidUsernameDataProvider(): array
{
return [
['_username'],

View file

@ -31,7 +31,7 @@ class AdminAclTest extends TestCase
/**
* Provide valid and invalid permissions combos for testing.
*/
public function permissionsDataProvider(): array
public static function permissionsDataProvider(): array
{
return [
[AdminAcl::READ, AdminAcl::READ, true],