diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index 684331e99..6ad3722d2 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -4,39 +4,21 @@ declare(strict_types=1); namespace Pterodactyl\Tests\Integration\Api\Client; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Http\Request; use Illuminate\Http\Response; use InvalidArgumentException; use Pterodactyl\Models\Allocation; use Pterodactyl\Models\Backup; -use Pterodactyl\Models\Database; -use Pterodactyl\Models\DatabaseHost; -use Pterodactyl\Models\Location; -use Pterodactyl\Models\Node; use Pterodactyl\Models\Schedule; use Pterodactyl\Models\Server; use Pterodactyl\Models\Task; -use Pterodactyl\Models\User; use Pterodactyl\Tests\Integration\IntegrationTestCase; use Pterodactyl\Tests\Integration\TestResponse; abstract class ClientApiIntegrationTestCase extends IntegrationTestCase { - /** - * Cleanup after running tests. - */ - protected function tearDown(): void - { - Database::query()->forceDelete(); - DatabaseHost::query()->forceDelete(); - Backup::query()->forceDelete(); - Server::query()->forceDelete(); - Node::query()->forceDelete(); - Location::query()->forceDelete(); - User::query()->forceDelete(); - - parent::tearDown(); - } + use DatabaseTransactions; /** * Override the default createTestResponse from Illuminate so that we can diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index 034e8c222..559f1a312 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Pterodactyl\Tests\Pest\Integration\Api\Remote\SftpAuthenticationControllerTest; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; use phpseclib3\Crypt\EC; @@ -18,7 +19,7 @@ use Pterodactyl\Tests\Integration\IntegrationTestCase; use function pterodactylTestCase; -uses(IntegrationTestCase::class); +uses(IntegrationTestCase::class, DatabaseTransactions::class); /** * Sets up the tests. */ diff --git a/tests/Integration/Console/Commands/Location/LocationCommandsTest.php b/tests/Integration/Console/Commands/Location/LocationCommandsTest.php index 86234a6da..33f326ac9 100644 --- a/tests/Integration/Console/Commands/Location/LocationCommandsTest.php +++ b/tests/Integration/Console/Commands/Location/LocationCommandsTest.php @@ -4,11 +4,12 @@ declare(strict_types=1); namespace Pterodactyl\Tests\Pest\Integration\Console\Commands\Location\LocationCommandsTest; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Pterodactyl\Models\Location; use Pterodactyl\Models\Node; use Pterodactyl\Tests\Integration\IntegrationTestCase; -uses(IntegrationTestCase::class); +uses(IntegrationTestCase::class, DatabaseTransactions::class); test('make creates a location', function () { $this->artisan('p:location:make', ['--short' => 'cli-made', '--long' => 'Made from the CLI'])->assertExitCode(0); $this->assertDatabaseHas('locations', ['short' => 'cli-made', 'long' => 'Made from the CLI']); diff --git a/tests/Integration/Http/HttpTestCase.php b/tests/Integration/Http/HttpTestCase.php index d79a03f8e..1defb1f3d 100644 --- a/tests/Integration/Http/HttpTestCase.php +++ b/tests/Integration/Http/HttpTestCase.php @@ -4,6 +4,10 @@ declare(strict_types=1); namespace Pterodactyl\Tests\Integration\Http; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Pterodactyl\Tests\Integration\IntegrationTestCase; -abstract class HttpTestCase extends IntegrationTestCase {} +abstract class HttpTestCase extends IntegrationTestCase +{ + use DatabaseTransactions; +} diff --git a/tests/Integration/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php b/tests/Integration/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php index a4fe861ad..8a6d4d85a 100644 --- a/tests/Integration/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php +++ b/tests/Integration/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Pterodactyl\Tests\Pest\Integration\Http\Middleware\Api\Daemon\DaemonAuthenticateTest; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Pterodactyl\Http\Middleware\Api\Daemon\DaemonAuthenticate; use Pterodactyl\Models\Node; use Pterodactyl\Tests\Assertions\MiddlewareAttributeAssertionsTrait; @@ -14,7 +15,7 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpException; -uses(IntegrationTestCase::class, RequestMockHelpers::class, MocksMiddlewareClosure::class, MiddlewareAttributeAssertionsTrait::class); +uses(IntegrationTestCase::class, DatabaseTransactions::class, RequestMockHelpers::class, MocksMiddlewareClosure::class, MiddlewareAttributeAssertionsTrait::class); beforeEach(function () { $this->buildRequestMock(); });