Fix tests with model events

This commit is contained in:
DaneEveritt 2022-05-29 17:07:34 -04:00
parent 2fc5a734f9
commit f1c1699994
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 7 additions and 25 deletions

View file

@ -22,7 +22,7 @@ class AllocationFactory extends Factory
{ {
return [ return [
'ip' => $this->faker->unique()->ipv4, 'ip' => $this->faker->unique()->ipv4,
'port' => $this->faker->unique()->randomNumber(5), 'port' => $this->faker->unique()->numberBetween(10000, 20000),
]; ];
} }

View file

@ -38,8 +38,11 @@ class ServerFactory extends Factory
'cpu' => 0, 'cpu' => 0,
'threads' => null, 'threads' => null,
'oom_disabled' => 0, 'oom_disabled' => 0,
'allocation_limit' => null, 'startup' => '/bin/bash echo "hello world"',
'database_limit' => null, 'image' => 'foo/bar:latest',
'allocation_limit' => 0,
'database_limit' => 0,
'backup_limit' => 0,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
'updated_at' => Carbon::now(), 'updated_at' => Carbon::now(),
]; ];

View file

@ -4,7 +4,6 @@ namespace Pterodactyl\Tests\Integration;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Pterodactyl\Tests\TestCase; use Pterodactyl\Tests\TestCase;
use Illuminate\Database\Eloquent\Model;
use Pterodactyl\Tests\Traits\Integration\CreatesTestModels; use Pterodactyl\Tests\Traits\Integration\CreatesTestModels;
use Pterodactyl\Transformers\Api\Application\BaseTransformer; use Pterodactyl\Transformers\Api\Application\BaseTransformer;
@ -12,27 +11,7 @@ abstract class IntegrationTestCase extends TestCase
{ {
use CreatesTestModels; use CreatesTestModels;
/** protected array $connectionsToTransact = ['mysql'];
* 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'];
}
/** /**
* Return an ISO-8601 formatted timestamp to use in the API response. * Return an ISO-8601 formatted timestamp to use in the API response.