mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-19 14:53:45 +02:00
tests(integration): fix new tests using legacy factories
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace Pterodactyl\Models;
|
namespace Pterodactyl\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -24,6 +25,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
*/
|
*/
|
||||||
class Backup extends Model
|
class Backup extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
const RESOURCE_NAME = 'backup';
|
const RESOURCE_NAME = 'backup';
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Allocation;
|
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Allocation;
|
||||||
|
|
||||||
use Pterodactyl\Models\Subuser;
|
use Pterodactyl\Models\Subuser;
|
||||||
use Pterodactyl\Models\Schedule;
|
|
||||||
use Pterodactyl\Models\Allocation;
|
use Pterodactyl\Models\Allocation;
|
||||||
use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
|
use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
|
||||||
|
|
||||||
@@ -25,11 +24,11 @@ class AllocationAuthorizationTest extends ClientApiIntegrationTestCase
|
|||||||
|
|
||||||
// Set the API $user as a subuser of server 2, but with no permissions
|
// Set the API $user as a subuser of server 2, but with no permissions
|
||||||
// to do anything with the allocations for that server.
|
// to do anything with the allocations for that server.
|
||||||
factory(Subuser::class)->create(['server_id' => $server2->id, 'user_id' => $user->id]);
|
Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]);
|
||||||
|
|
||||||
$allocation1 = factory(Allocation::class)->create(['server_id' => $server1->id, 'node_id' => $server1->node_id]);
|
$allocation1 = Allocation::factory()->create(['server_id' => $server1->id, 'node_id' => $server1->node_id]);
|
||||||
$allocation2 = factory(Allocation::class)->create(['server_id' => $server2->id, 'node_id' => $server2->node_id]);
|
$allocation2 = Allocation::factory()->create(['server_id' => $server2->id, 'node_id' => $server2->node_id]);
|
||||||
$allocation3 = factory(Allocation::class)->create(['server_id' => $server3->id, 'node_id' => $server3->node_id]);
|
$allocation3 = Allocation::factory()->create(['server_id' => $server3->id, 'node_id' => $server3->node_id]);
|
||||||
|
|
||||||
// This is the only valid call for this test, accessing the allocation for the same
|
// This is the only valid call for this test, accessing the allocation for the same
|
||||||
// server that the API user is the owner of.
|
// server that the API user is the owner of.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase
|
|||||||
{
|
{
|
||||||
// Generic subuser, the specific resource we're trying to access.
|
// Generic subuser, the specific resource we're trying to access.
|
||||||
/** @var \Pterodactyl\Models\User $internal */
|
/** @var \Pterodactyl\Models\User $internal */
|
||||||
$internal = factory(User::class)->create();
|
$internal = User::factory()->create();
|
||||||
|
|
||||||
// The API $user is the owner of $server1.
|
// The API $user is the owner of $server1.
|
||||||
[$user, $server1] = $this->generateTestAccount();
|
[$user, $server1] = $this->generateTestAccount();
|
||||||
@@ -31,11 +31,11 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase
|
|||||||
|
|
||||||
// Set the API $user as a subuser of server 2, but with no permissions
|
// Set the API $user as a subuser of server 2, but with no permissions
|
||||||
// to do anything with the subusers for that server.
|
// to do anything with the subusers for that server.
|
||||||
factory(Subuser::class)->create(['server_id' => $server2->id, 'user_id' => $user->id]);
|
Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]);
|
||||||
|
|
||||||
factory(Subuser::class)->create(['server_id' => $server1->id, 'user_id' => $internal->id]);
|
Subuser::factory()->create(['server_id' => $server1->id, 'user_id' => $internal->id]);
|
||||||
factory(Subuser::class)->create(['server_id' => $server2->id, 'user_id' => $internal->id]);
|
Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $internal->id]);
|
||||||
factory(Subuser::class)->create(['server_id' => $server3->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') {
|
if ($method === 'DELETE') {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ abstract class TestCase extends BaseTestCase
|
|||||||
|
|
||||||
// Why, you ask? If we don't force this to false it is possible for certain exceptions
|
// Why, you ask? If we don't force this to false it is possible for certain exceptions
|
||||||
// to show their error message properly in the integration test output, but not actually
|
// to show their error message properly in the integration test output, but not actually
|
||||||
// be setup correctly to display thier message in production.
|
// be setup correctly to display their message in production.
|
||||||
//
|
//
|
||||||
// If we expect a message in a test, and it isn't showing up (rather, showing the generic
|
// If we expect a message in a test, and it isn't showing up (rather, showing the generic
|
||||||
// "an error occurred" message), we can probably assume that the exception isn't one that
|
// "an error occurred" message), we can probably assume that the exception isn't one that
|
||||||
|
|||||||
Reference in New Issue
Block a user