From f1c169999401d2709ecfb61c721dc53a0405b357 Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Sun, 29 May 2022 17:07:34 -0400 Subject: [PATCH] Fix tests with model events --- database/Factories/AllocationFactory.php | 2 +- database/Factories/ServerFactory.php | 7 +++++-- tests/Integration/IntegrationTestCase.php | 23 +---------------------- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/database/Factories/AllocationFactory.php b/database/Factories/AllocationFactory.php index 9ed42e3ef..c65298ec4 100644 --- a/database/Factories/AllocationFactory.php +++ b/database/Factories/AllocationFactory.php @@ -22,7 +22,7 @@ class AllocationFactory extends Factory { return [ 'ip' => $this->faker->unique()->ipv4, - 'port' => $this->faker->unique()->randomNumber(5), + 'port' => $this->faker->unique()->numberBetween(10000, 20000), ]; } diff --git a/database/Factories/ServerFactory.php b/database/Factories/ServerFactory.php index d39d614b2..b9145c679 100644 --- a/database/Factories/ServerFactory.php +++ b/database/Factories/ServerFactory.php @@ -38,8 +38,11 @@ class ServerFactory extends Factory 'cpu' => 0, 'threads' => null, 'oom_disabled' => 0, - 'allocation_limit' => null, - 'database_limit' => null, + 'startup' => '/bin/bash echo "hello world"', + 'image' => 'foo/bar:latest', + 'allocation_limit' => 0, + 'database_limit' => 0, + 'backup_limit' => 0, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), ]; diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index f12eaaef1..c290f6070 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -4,7 +4,6 @@ namespace Pterodactyl\Tests\Integration; use Carbon\CarbonImmutable; use Pterodactyl\Tests\TestCase; -use Illuminate\Database\Eloquent\Model; use Pterodactyl\Tests\Traits\Integration\CreatesTestModels; use Pterodactyl\Transformers\Api\Application\BaseTransformer; @@ -12,27 +11,7 @@ abstract class IntegrationTestCase extends TestCase { use CreatesTestModels; - /** - * Setup base integration test cases. - */ - public function setUp(): void - { - parent::setUp(); - - // Disable event dispatcher to prevent eloquence from trying to - // perform validation on models going into the database. If this is - // not disabled, eloquence validation errors get swallowed and - // the tests cannot complete because nothing is put into the database. - Model::unsetEventDispatcher(); - } - - /** - * @return array - */ - protected function connectionsToTransact() - { - return ['testing']; - } + protected array $connectionsToTransact = ['mysql']; /** * Return an ISO-8601 formatted timestamp to use in the API response.