diff --git a/CMakeLists.txt b/CMakeLists.txt index e8d770f607..2cab51b749 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ find_program(NPX_EXE NAMES npx PATHS c:/usr/bin/npx /usr/bin/npx REQUIRED) set(PHPUNIT "${CDash_SOURCE_DIR}/vendor/bin/phpunit") set_property(GLOBAL PROPERTY INSTALL_CDASH_COUNT "0") -function(cdash_install TestName) +function(cdash_install TestName DatabaseName) add_test( NAME ${TestName} COMMAND ${PHP_EXE} ${testing_dir}/singletest.php ${testing_dir}/test_install.php @@ -69,6 +69,13 @@ function(cdash_install TestName) FAIL_REGULAR_EXPRESSION ".*Failures: [1-9]+.*;.*Exceptions: [1-9]+.*" ATTACHED_FILES_ON_FAIL "${CDash_SOURCE_DIR}/storage/logs/cdash.log" ) + + if(DatabaseName) + set_tests_properties( + ${TestName} PROPERTIES + ENVIRONMENT "DB_DATABASE=${DatabaseName}" + ) + endif() endfunction() # add the new tests directory diff --git a/app/cdash/tests/CMakeLists.txt b/app/cdash/tests/CMakeLists.txt index d5d76ac206..e8ba0debca 100644 --- a/app/cdash/tests/CMakeLists.txt +++ b/app/cdash/tests/CMakeLists.txt @@ -1,6 +1,7 @@ # We define these here so they can be referenced in functions below. -cdash_install(install_1) -cdash_install(install_2) +cdash_install(install_1 "") +cdash_install(install_2 "") +cdash_install(install_clean_database testing_clean) # function to add a new PHP based coverage test to CDash function(add_php_test TestName) @@ -65,6 +66,17 @@ function(add_feature_test TestName) ) endfunction() +# Tests which run entirely within a transaction, leaving no trace in the database. +function(add_feature_test_in_transaction TestName) + add_laravel_test(${TestName}) + set_property(TEST ${TestName} APPEND PROPERTY DEPENDS install_clean_database) + set_tests_properties( + ${TestName} PROPERTIES + ATTACHED_FILES_ON_FAIL "${CDash_SOURCE_DIR}/storage/logs/cdash.log" + ENVIRONMENT "DB_DATABASE=testing_clean" + ) +endfunction() + function(add_browser_test TestName) add_feature_test(${TestName}) set_property(TEST ${TestName} APPEND PROPERTY RESOURCE_LOCK @@ -158,104 +170,162 @@ add_legacy_unit_test(/CDash/XmlHandler/UpdateHandler) set_tests_properties(/CDash/XmlHandler/UpdateHandler PROPERTIES DEPENDS /CDash/XmlHandler/TestingHandler) ################################################################################################### -# Tests from this point to the next cdash_install() are expected to be completely independent. -# Tests may wipe the database, provided that they use RUN_SERIAL. All tests in this section should -# depend upon the last test prior to this section. +# Tests in this section are expected to run against the testing_clean database in transactions, +# such that the database is empty at any given point. -add_feature_test(/Feature/LoginAndRegistration) +add_feature_test_in_transaction(/Feature/LoginAndRegistration) -add_feature_test(/Feature/ProjectPermissions) +add_feature_test_in_transaction(/Feature/ProjectPermissions) -add_feature_test(/Feature/SlowPageTest) +add_feature_test_in_transaction(/Feature/SlowPageTest) -add_feature_test(/Feature/GitHubWebhook) +add_feature_test_in_transaction(/Feature/GitHubWebhook) -add_feature_test(/Feature/GlobalBannerTest) +add_feature_test_in_transaction(/Feature/GlobalBannerTest) -add_legacy_unit_test(/CDash/Lib/Repository/GitHub) -set_tests_properties(/CDash/Lib/Repository/GitHub PROPERTIES - DEPENDS /CDash/XmlHandler/UpdateHandler - DISABLED "$" -) +add_feature_test_in_transaction(/Feature/GraphQL/BuildTypeTest) -add_legacy_unit_test(/CDash/Messaging/Subscription/CommitAuthorSubscriptionBuilder) -set_tests_properties(/CDash/Messaging/Subscription/CommitAuthorSubscriptionBuilder PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) +add_feature_test_in_transaction(/Feature/ProjectInvitationAcceptanceTest) -add_legacy_unit_test(/CDash/Messaging/Subscription/UserSubscriptionBuilder) -set_tests_properties(/CDash/Messaging/Subscription/UserSubscriptionBuilder PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) +add_feature_test_in_transaction(/Feature/GraphQL/FilterTest) -add_legacy_unit_test(/CDash/Messaging/Topic/UpdateErrorTopic) -set_tests_properties(/CDash/Messaging/Topic/UpdateErrorTopic PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) +add_feature_test_in_transaction(/Feature/GraphQL/QueryTypeTest) -add_legacy_unit_test(/CDash/Service/RepositoryService) -set_tests_properties(/CDash/Service/RepositoryService PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) +add_feature_test_in_transaction(/Feature/GraphQL/UserTypeTest) -# Set this to RUN_SERIAL as we are changing the config and don't want to clobber other tests. -# Only requires exclusive .env access. -add_feature_test(/Feature/SubmissionValidation) -set_property(TEST /Feature/SubmissionValidation APPEND PROPERTY RUN_SERIAL TRUE) +add_feature_test_in_transaction(/Feature/GraphQL/ProjectTypeTest) -add_feature_test(/Feature/ProjectInvitationAcceptanceTest) +add_feature_test_in_transaction(/Feature/GraphQL/SiteTypeTest) -add_feature_test(/Feature/GraphQL/FilterTest) -set_property(TEST /Feature/GraphQL/FilterTest APPEND PROPERTY RUN_SERIAL TRUE) +add_feature_test_in_transaction(/Feature/GraphQL/ConfigureTypeTest) -add_feature_test(/Feature/GraphQL/QueryTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/TestTypeTest) -add_feature_test(/Feature/GraphQL/UserTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/TestMeasurementTypeTest) -add_feature_test(/Feature/GraphQL/ProjectTypeTest) -set_property(TEST /Feature/GraphQL/ProjectTypeTest APPEND PROPERTY RUN_SERIAL TRUE) +add_feature_test_in_transaction(/Feature/GraphQL/NoteTypeTest) -add_feature_test(/Feature/GraphQL/SiteTypeTest) -set_property(TEST /Feature/GraphQL/SiteTypeTest APPEND PROPERTY RUN_SERIAL TRUE) +add_feature_test_in_transaction(/Feature/GraphQL/CoverageTypeTest) -add_feature_test(/Feature/GraphQL/BuildTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/DynamicAnalysisTypeTest) -add_feature_test(/Feature/GraphQL/ConfigureTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/DynamicAnalysisDefectTypeTest) -add_feature_test(/Feature/GraphQL/TestTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/ProjectInvitationTypeTest) -add_feature_test(/Feature/GraphQL/TestMeasurementTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/LabelTypeTest) -add_feature_test(/Feature/GraphQL/NoteTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/TargetTypeTest) -add_feature_test(/Feature/GraphQL/CoverageTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/BuildCommandTypeTest) -add_feature_test(/Feature/GraphQL/DynamicAnalysisTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/BuildCommandOutputTypeTest) -add_feature_test(/Feature/GraphQL/DynamicAnalysisDefectTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/UpdateTypeTest) -add_feature_test(/Feature/GraphQL/ProjectInvitationTypeTest) +add_feature_test_in_transaction(/Feature/GraphQL/UpdateFileTypeTest) -add_feature_test(/Feature/GraphQL/LabelTypeTest) +add_feature_test_in_transaction(/Feature/RouteAccessTest) -add_feature_test(/Feature/GraphQL/TargetTypeTest) +add_feature_test_in_transaction(/Feature/Monitor) -add_feature_test(/Feature/GraphQL/BuildCommandTypeTest) +add_feature_test_in_transaction(/Feature/PasswordRotation) -add_feature_test(/Feature/GraphQL/BuildCommandOutputTypeTest) +add_feature_test_in_transaction(/Feature/PurgeUnusedProjectsCommand) -add_feature_test(/Feature/GraphQL/UpdateTypeTest) +add_feature_test_in_transaction(/Feature/Jobs/PruneJobsTest) -add_feature_test(/Feature/GraphQL/UpdateFileTypeTest) +add_feature_test_in_transaction(/Feature/Jobs/PruneAuthTokensTest) -add_feature_test(/Feature/Submission/Instrumentation/BuildInstrumentationTest) -add_feature_test(/Feature/Submission/Tests/TestXMLTest) +add_feature_test_in_transaction(/Feature/UserCommand) -add_feature_test(/Feature/RouteAccessTest) +add_feature_test_in_transaction(/Feature/RemoteWorkers) +set_property(TEST /Feature/RemoteWorkers APPEND PROPERTY + DISABLED "$>" +) -add_feature_test(/Feature/Monitor) -set_property(TEST /Feature/Monitor APPEND PROPERTY RUN_SERIAL TRUE) +add_feature_test_in_transaction(/Feature/Jobs/NotifyExpiringAuthTokensTest) -add_feature_test(/Feature/PasswordRotation) +add_feature_test_in_transaction(/Feature/Jobs/PruneUploadsTest) -add_browser_test(/Browser/Pages/SitesIdPageTest) +add_feature_test_in_transaction(/Feature/Mail/AuthTokenExpiringTest) + +add_feature_test_in_transaction(/Feature/Mail/AuthTokenExpiredTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/CreateProjectTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/UpdateSiteDescriptionTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/InviteToProjectTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/RevokeProjectInvitationTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/ChangeProjectRoleTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/RemoveProjectUserTest) + +add_feature_test_in_transaction(/Feature/Traits/UpdatesSiteInformationTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/ChangeGlobalRoleTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/JoinProjectTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/CreateGlobalInvitationTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/RevokeGlobalInvitationTest) + +add_feature_test_in_transaction(/Feature/GlobalInvitationAcceptanceTest) + +add_feature_test_in_transaction(/Feature/GraphQL/GlobalInvitationTypeTest) + +add_feature_test_in_transaction(/Feature/GraphQL/Mutations/RemoveUserTest) + +add_feature_test_in_transaction(/Feature/Jobs/PruneBuildsTest) + +add_feature_test_in_transaction(/Feature/Jobs/PruneEmailsTest) + +add_feature_test_in_transaction(/Feature/Services/ProjectServiceTest) + +add_feature_test_in_transaction(/Feature/AutoRemoveBuildsCommand) + +################################################################################################### +# Tests from this point to the next cdash_install() are expected to be completely independent. +# Tests may wipe the database, provided that they use RUN_SERIAL. All tests in this section should +# depend upon the last test prior to this section. + +add_legacy_unit_test(/CDash/Lib/Repository/GitHub) +set_tests_properties(/CDash/Lib/Repository/GitHub PROPERTIES + DEPENDS /CDash/XmlHandler/UpdateHandler + DISABLED "$" +) + +add_legacy_unit_test(/CDash/Messaging/Subscription/CommitAuthorSubscriptionBuilder) +set_tests_properties(/CDash/Messaging/Subscription/CommitAuthorSubscriptionBuilder PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) + +add_legacy_unit_test(/CDash/Messaging/Subscription/UserSubscriptionBuilder) +set_tests_properties(/CDash/Messaging/Subscription/UserSubscriptionBuilder PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) + +add_legacy_unit_test(/CDash/Messaging/Topic/UpdateErrorTopic) +set_tests_properties(/CDash/Messaging/Topic/UpdateErrorTopic PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) + +add_legacy_unit_test(/CDash/Service/RepositoryService) +set_tests_properties(/CDash/Service/RepositoryService PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) + +# Set this to RUN_SERIAL as we are changing the config and don't want to clobber other tests. +# Only requires exclusive .env access. +add_feature_test(/Feature/SubmissionValidation) +set_property(TEST /Feature/SubmissionValidation APPEND PROPERTY RUN_SERIAL TRUE) # Technically this test doesn't have to run serially. It just needs to have exclusive access to the .env add_feature_test(/Feature/LdapIntegration) set_property(TEST /Feature/LdapIntegration APPEND PROPERTY RUN_SERIAL TRUE) +add_feature_test(/Feature/Submission/Instrumentation/BuildInstrumentationTest) + +add_feature_test(/Feature/Submission/Tests/TestXMLTest) + +add_browser_test(/Browser/Pages/SitesIdPageTest) + add_browser_test(/Browser/Pages/ProjectSitesPageTest) add_browser_test(/Browser/Pages/ProjectMembersPageTest) @@ -265,17 +335,6 @@ add_browser_test(/Browser/Pages/ProjectBuildsPageTest) add_browser_test(/Browser/Pages/ProjectsPageTest) set_property(TEST /Browser/Pages/ProjectsPageTest APPEND PROPERTY RUN_SERIAL TRUE) -add_feature_test(/Feature/PurgeUnusedProjectsCommand) -set_property(TEST /Feature/PurgeUnusedProjectsCommand APPEND PROPERTY RUN_SERIAL TRUE) - -# This could theoretically conflict with another test removing jobs from the submission tables in the future -add_feature_test(/Feature/Jobs/PruneJobsTest) - -add_feature_test(/Feature/Jobs/PruneAuthTokensTest) -set_property(TEST /Feature/Jobs/PruneAuthTokensTest APPEND PROPERTY RUN_SERIAL TRUE) - -add_feature_test(/Feature/UserCommand) - add_legacy_unit_test(/CDash/Database) set_tests_properties(/CDash/Database PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) @@ -306,54 +365,6 @@ set_tests_properties(/CDash/Messaging/Topic/TestFailureTopic PROPERTIES DEPENDS add_legacy_unit_test(/CDash/Messaging/Topic/TopicDecorator) set_tests_properties(/CDash/Messaging/Topic/TopicDecorator PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) -add_feature_test(/Feature/RemoteWorkers) -set_property(TEST /Feature/RemoteWorkers APPEND PROPERTY - DISABLED "$>" -) - -add_feature_test(/Feature/Jobs/NotifyExpiringAuthTokensTest) -set_property(TEST /Feature/Jobs/NotifyExpiringAuthTokensTest APPEND PROPERTY RUN_SERIAL TRUE) - -add_feature_test(/Feature/Jobs/PruneUploadsTest) - -add_feature_test(/Feature/Mail/AuthTokenExpiringTest) - -add_feature_test(/Feature/Mail/AuthTokenExpiredTest) - -add_feature_test(/Feature/GraphQL/Mutations/CreateProjectTest) - -add_feature_test(/Feature/GraphQL/Mutations/UpdateSiteDescriptionTest) - -add_feature_test(/Feature/GraphQL/Mutations/InviteToProjectTest) - -add_feature_test(/Feature/GraphQL/Mutations/RevokeProjectInvitationTest) - -add_feature_test(/Feature/GraphQL/Mutations/ChangeProjectRoleTest) - -add_feature_test(/Feature/GraphQL/Mutations/RemoveProjectUserTest) - -add_feature_test(/Feature/Traits/UpdatesSiteInformationTest) - -add_feature_test(/Feature/GraphQL/Mutations/ChangeGlobalRoleTest) - -add_feature_test(/Feature/GraphQL/Mutations/JoinProjectTest) - -# Needs RUN_SERIAL to verify that no unexpected invitations are created -add_feature_test(/Feature/GraphQL/Mutations/CreateGlobalInvitationTest) -set_property(TEST /Feature/GraphQL/Mutations/CreateGlobalInvitationTest APPEND PROPERTY RUN_SERIAL TRUE) - -add_feature_test(/Feature/GraphQL/Mutations/RevokeGlobalInvitationTest) - -# Needs RUN_SERIAL to verify that only the expected users are created -add_feature_test(/Feature/GlobalInvitationAcceptanceTest) -set_property(TEST /Feature/GlobalInvitationAcceptanceTest APPEND PROPERTY RUN_SERIAL TRUE) - -# Requires exclusive access to the global_invitations table -add_feature_test(/Feature/GraphQL/GlobalInvitationTypeTest) -set_property(TEST /Feature/GraphQL/GlobalInvitationTypeTest APPEND PROPERTY RUN_SERIAL TRUE) - -add_feature_test(/Feature/GraphQL/Mutations/RemoveUserTest) - add_browser_test(/Browser/Pages/UsersPageTest) add_browser_test(/Browser/Pages/BuildFilesPageTest) @@ -413,19 +424,6 @@ set_tests_properties(configurewarnings PROPERTIES DEPENDS /CDash/XmlHandler/Upda add_php_test(lotsofsubprojects) set_tests_properties(lotsofsubprojects PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler) -add_feature_test(/Feature/AutoRemoveBuildsCommand) - -# Must run serially since it can delete builds other than the ones it creates. -add_feature_test(/Feature/Jobs/PruneBuildsTest) -set_property(TEST /Feature/Jobs/PruneBuildsTest APPEND PROPERTY RUN_SERIAL TRUE) - -# Theoretically it's possible for this test to conflict with other tests because this test can -# delete email history records other than the ones it creates. The odds of such a conflict -# occurring are too low to justify running serially. -add_feature_test(/Feature/Jobs/PruneEmailsTest) - -add_feature_test(/Feature/Services/ProjectServiceTest) - ################################################################################################### set_property(TEST install_2 APPEND PROPERTY DEPENDS diff --git a/app/cdash/tests/test_install.php b/app/cdash/tests/test_install.php index 3698719d62..41d840dab9 100644 --- a/app/cdash/tests/test_install.php +++ b/app/cdash/tests/test_install.php @@ -19,12 +19,6 @@ public function __construct() public function testInstall() { - // double check that it's the testing database before doing anything hasty... - if ($this->databaseName !== 'cdash4simpletest') { - $this->fail("can only test on a database named 'cdash4simpletest'"); - return 1; - } - // drop any old testing database before testing install $success = $this->db->drop($this->databaseName); if (!$success) { @@ -36,14 +30,17 @@ public function testInstall() Artisan::call('migrate', ['--force' => true]); - Artisan::call('user:save', [ - '--email' => 'simpletest@localhost', - '--firstname' => 'administrator', - '--lastname' => '', - '--password' => 'simpletest', - '--institution' => 'Kitware Inc.', - '--admin' => 1, - ]); + // A hack to ensure that only the legacy testing database has this user. + if ($this->databaseName === 'cdash4simpletest') { + Artisan::call('user:save', [ + '--email' => 'simpletest@localhost', + '--firstname' => 'administrator', + '--lastname' => '', + '--password' => 'simpletest', + '--institution' => 'Kitware Inc.', + '--admin' => 1, + ]); + } $this->pass('Passed'); } diff --git a/tests/Browser/Pages/BuildConfigurePageTest.php b/tests/Browser/Pages/BuildConfigurePageTest.php index d77017795e..b982c997fb 100644 --- a/tests/Browser/Pages/BuildConfigurePageTest.php +++ b/tests/Browser/Pages/BuildConfigurePageTest.php @@ -64,14 +64,14 @@ public function setUp(): void public function tearDown(): void { - parent::tearDown(); - $this->project->delete(); $this->site->delete(); foreach ($this->configures as $configure) { $configure->delete(); } + + parent::tearDown(); } public function testShowsBuildName(): void diff --git a/tests/Browser/Pages/BuildCoveragePageTest.php b/tests/Browser/Pages/BuildCoveragePageTest.php index ff1c8e34a1..6e937dc7e4 100644 --- a/tests/Browser/Pages/BuildCoveragePageTest.php +++ b/tests/Browser/Pages/BuildCoveragePageTest.php @@ -46,10 +46,10 @@ public function setUp(): void public function tearDown(): void { - parent::tearDown(); - $this->project->delete(); $this->site->delete(); + + parent::tearDown(); } private function createCoverage( diff --git a/tests/Browser/Pages/BuildFilesPageTest.php b/tests/Browser/Pages/BuildFilesPageTest.php index 8d0987f0fc..4e6b2b8c81 100644 --- a/tests/Browser/Pages/BuildFilesPageTest.php +++ b/tests/Browser/Pages/BuildFilesPageTest.php @@ -51,8 +51,6 @@ public function setUp(): void public function tearDown(): void { - parent::tearDown(); - $this->project->delete(); $this->site->delete(); @@ -60,6 +58,8 @@ public function tearDown(): void $file->delete(); } $this->files = []; + + parent::tearDown(); } private function addUploadedFile(bool $url = false): UploadFile diff --git a/tests/Browser/Pages/BuildNotesPageTest.php b/tests/Browser/Pages/BuildNotesPageTest.php index 9aa2e59dbd..accb4ca3e4 100644 --- a/tests/Browser/Pages/BuildNotesPageTest.php +++ b/tests/Browser/Pages/BuildNotesPageTest.php @@ -54,8 +54,6 @@ public function setUp(): void public function tearDown(): void { - parent::tearDown(); - $this->project->delete(); $this->site->delete(); @@ -63,6 +61,8 @@ public function tearDown(): void $note->delete(); } $this->notes = collect(); + + parent::tearDown(); } private function addNote(): Note diff --git a/tests/Browser/Pages/BuildTargetsPageTest.php b/tests/Browser/Pages/BuildTargetsPageTest.php index e56f9c79ba..521ce53a6f 100644 --- a/tests/Browser/Pages/BuildTargetsPageTest.php +++ b/tests/Browser/Pages/BuildTargetsPageTest.php @@ -47,10 +47,10 @@ public function setUp(): void public function tearDown(): void { - parent::tearDown(); - $this->project->delete(); $this->site->delete(); + + parent::tearDown(); } private function addTarget(TargetType $type = TargetType::UNKNOWN): Target diff --git a/tests/Browser/Pages/BuildTestsPageTest.php b/tests/Browser/Pages/BuildTestsPageTest.php index 6209952cec..e4456f99e1 100644 --- a/tests/Browser/Pages/BuildTestsPageTest.php +++ b/tests/Browser/Pages/BuildTestsPageTest.php @@ -46,11 +46,11 @@ public function setUp(): void public function tearDown(): void { - parent::tearDown(); - $this->project->delete(); $this->testOutput->delete(); $this->site->delete(); + + parent::tearDown(); } public function testShowsBuildName(): void diff --git a/tests/Browser/Pages/ProjectBuildsPageTest.php b/tests/Browser/Pages/ProjectBuildsPageTest.php index adc7e901f5..df43640b82 100644 --- a/tests/Browser/Pages/ProjectBuildsPageTest.php +++ b/tests/Browser/Pages/ProjectBuildsPageTest.php @@ -23,9 +23,9 @@ public function setUp(): void public function tearDown(): void { - parent::tearDown(); - $this->project->delete(); + + parent::tearDown(); } public function testProjectPageDisplaysBanner(): void diff --git a/tests/Browser/Pages/ProjectMembersPageTest.php b/tests/Browser/Pages/ProjectMembersPageTest.php index c1ddc0b2f2..ed9e46af6c 100644 --- a/tests/Browser/Pages/ProjectMembersPageTest.php +++ b/tests/Browser/Pages/ProjectMembersPageTest.php @@ -32,14 +32,14 @@ public function setUp(): void public function tearDown(): void { - parent::tearDown(); - $this->project->delete(); foreach ($this->users as $users) { $users->delete(); } $this->users = []; + + parent::tearDown(); } private function addUserToProject(bool $admin = false): User diff --git a/tests/Browser/Pages/ProjectSitesPageTest.php b/tests/Browser/Pages/ProjectSitesPageTest.php index 16ba44a0d5..4983d09e44 100644 --- a/tests/Browser/Pages/ProjectSitesPageTest.php +++ b/tests/Browser/Pages/ProjectSitesPageTest.php @@ -27,8 +27,6 @@ class ProjectSitesPageTest extends BrowserTestCase public function tearDown(): void { - parent::tearDown(); - foreach ($this->projects as $project) { $project->delete(); } @@ -38,6 +36,8 @@ public function tearDown(): void $site->delete(); } $this->sites = []; + + parent::tearDown(); } public function testSiteDisplaysLatestInformation(): void diff --git a/tests/Browser/Pages/SitesIdPageTest.php b/tests/Browser/Pages/SitesIdPageTest.php index 48f9997076..130e8f80b3 100644 --- a/tests/Browser/Pages/SitesIdPageTest.php +++ b/tests/Browser/Pages/SitesIdPageTest.php @@ -36,8 +36,6 @@ class SitesIdPageTest extends BrowserTestCase public function tearDown(): void { - parent::tearDown(); - foreach ($this->projects as $project) { $project->delete(); } @@ -52,6 +50,8 @@ public function tearDown(): void $users->delete(); } $this->users = []; + + parent::tearDown(); } public function testMostRecentSiteDetails(): void diff --git a/tests/Feature/AutoRemoveBuildsCommand.php b/tests/Feature/AutoRemoveBuildsCommand.php index 36bd043cc4..e56b98e7d5 100644 --- a/tests/Feature/AutoRemoveBuildsCommand.php +++ b/tests/Feature/AutoRemoveBuildsCommand.php @@ -8,10 +8,13 @@ use CDash\Model\Build; use DateTime; use DateTimeZone; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; class AutoRemoveBuildsCommand extends TestCase { + use DatabaseTransactions; + protected Project $project; public function setUp(): void diff --git a/tests/Feature/GitHubWebhook.php b/tests/Feature/GitHubWebhook.php index bb97ed543d..660f98d197 100644 --- a/tests/Feature/GitHubWebhook.php +++ b/tests/Feature/GitHubWebhook.php @@ -2,10 +2,13 @@ namespace Tests\Feature; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; class GitHubWebhook extends TestCase { + use DatabaseTransactions; + protected string $endpoint = '/api/v1/GitHub/webhook.php'; public function setUp(): void diff --git a/tests/Feature/GlobalBannerTest.php b/tests/Feature/GlobalBannerTest.php index 941c4845d8..f0e3fa8c6a 100644 --- a/tests/Feature/GlobalBannerTest.php +++ b/tests/Feature/GlobalBannerTest.php @@ -2,11 +2,14 @@ namespace Tests\Feature; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use Tests\TestCase; class GlobalBannerTest extends TestCase { + use DatabaseTransactions; + public function testGlobalBannerAppearsWhenSet(): void { $bannerText = Str::uuid()->toString(); diff --git a/tests/Feature/GlobalInvitationAcceptanceTest.php b/tests/Feature/GlobalInvitationAcceptanceTest.php index 7fd11098cb..bd143197e9 100644 --- a/tests/Feature/GlobalInvitationAcceptanceTest.php +++ b/tests/Feature/GlobalInvitationAcceptanceTest.php @@ -5,7 +5,7 @@ use App\Enums\GlobalRole; use App\Models\GlobalInvitation; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseTruncation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Hash; @@ -16,7 +16,7 @@ class GlobalInvitationAcceptanceTest extends TestCase { use CreatesUsers; - use DatabaseTruncation; + use DatabaseTransactions; /** * @var array diff --git a/tests/Feature/GraphQL/BuildCommandOutputTypeTest.php b/tests/Feature/GraphQL/BuildCommandOutputTypeTest.php index 102a3fe282..5590a8e61f 100644 --- a/tests/Feature/GraphQL/BuildCommandOutputTypeTest.php +++ b/tests/Feature/GraphQL/BuildCommandOutputTypeTest.php @@ -7,6 +7,7 @@ use App\Models\BuildCommand; use App\Models\BuildCommandOutput; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use Tests\TestCase; @@ -15,6 +16,7 @@ class BuildCommandOutputTypeTest extends TestCase { use CreatesProjects; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/BuildCommandTypeTest.php b/tests/Feature/GraphQL/BuildCommandTypeTest.php index 10b01df447..7177f04104 100644 --- a/tests/Feature/GraphQL/BuildCommandTypeTest.php +++ b/tests/Feature/GraphQL/BuildCommandTypeTest.php @@ -6,6 +6,7 @@ use App\Models\Build; use App\Models\BuildCommand; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use PHPUnit\Framework\Attributes\DataProvider; @@ -17,6 +18,7 @@ class BuildCommandTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/BuildTypeTest.php b/tests/Feature/GraphQL/BuildTypeTest.php index 879ed82021..608e6f0304 100644 --- a/tests/Feature/GraphQL/BuildTypeTest.php +++ b/tests/Feature/GraphQL/BuildTypeTest.php @@ -8,6 +8,7 @@ use App\Models\CoverageFile; use App\Models\Project; use App\Models\Target; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use PHPUnit\Framework\Attributes\DataProvider; @@ -19,6 +20,7 @@ class BuildTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; private Project $project2; diff --git a/tests/Feature/GraphQL/ConfigureTypeTest.php b/tests/Feature/GraphQL/ConfigureTypeTest.php index 4a2c177235..f99784eec5 100644 --- a/tests/Feature/GraphQL/ConfigureTypeTest.php +++ b/tests/Feature/GraphQL/ConfigureTypeTest.php @@ -6,6 +6,7 @@ use App\Models\BuildConfigure; use App\Models\Configure; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -15,6 +16,7 @@ class ConfigureTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/CoverageTypeTest.php b/tests/Feature/GraphQL/CoverageTypeTest.php index ee10505908..b5c2e9fe3a 100644 --- a/tests/Feature/GraphQL/CoverageTypeTest.php +++ b/tests/Feature/GraphQL/CoverageTypeTest.php @@ -6,6 +6,7 @@ use App\Models\CoverageFile; use App\Models\Label; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use Tests\TestCase; @@ -16,6 +17,7 @@ class CoverageTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/DynamicAnalysisDefectTypeTest.php b/tests/Feature/GraphQL/DynamicAnalysisDefectTypeTest.php index ea3b529dc2..a9b6142748 100644 --- a/tests/Feature/GraphQL/DynamicAnalysisDefectTypeTest.php +++ b/tests/Feature/GraphQL/DynamicAnalysisDefectTypeTest.php @@ -6,6 +6,7 @@ use App\Models\DynamicAnalysis; use App\Models\DynamicAnalysisDefect; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -15,6 +16,7 @@ class DynamicAnalysisDefectTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/DynamicAnalysisTypeTest.php b/tests/Feature/GraphQL/DynamicAnalysisTypeTest.php index fffb02754e..05743d6628 100644 --- a/tests/Feature/GraphQL/DynamicAnalysisTypeTest.php +++ b/tests/Feature/GraphQL/DynamicAnalysisTypeTest.php @@ -5,6 +5,7 @@ use App\Models\Build; use App\Models\DynamicAnalysis; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -14,6 +15,7 @@ class DynamicAnalysisTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/FilterTest.php b/tests/Feature/GraphQL/FilterTest.php index dcb121798f..526a7d70e4 100644 --- a/tests/Feature/GraphQL/FilterTest.php +++ b/tests/Feature/GraphQL/FilterTest.php @@ -9,7 +9,7 @@ use App\Models\Test; use App\Models\TestOutput; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseTruncation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use Tests\TestCase; @@ -22,7 +22,7 @@ class FilterTest extends TestCase use CreatesProjects; use CreatesSites; use CreatesUsers; - use DatabaseTruncation; + use DatabaseTransactions; /** * @var array diff --git a/tests/Feature/GraphQL/GlobalInvitationTypeTest.php b/tests/Feature/GraphQL/GlobalInvitationTypeTest.php index e895378c76..852ccb0fc0 100644 --- a/tests/Feature/GraphQL/GlobalInvitationTypeTest.php +++ b/tests/Feature/GraphQL/GlobalInvitationTypeTest.php @@ -5,7 +5,7 @@ use App\Enums\GlobalRole; use App\Models\GlobalInvitation; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseTruncation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; @@ -15,7 +15,7 @@ class GlobalInvitationTypeTest extends TestCase { use CreatesUsers; - use DatabaseTruncation; + use DatabaseTransactions; private User $normalUser; private User $adminUser; diff --git a/tests/Feature/GraphQL/LabelTypeTest.php b/tests/Feature/GraphQL/LabelTypeTest.php index 31ee821bce..4a071e89dd 100644 --- a/tests/Feature/GraphQL/LabelTypeTest.php +++ b/tests/Feature/GraphQL/LabelTypeTest.php @@ -5,6 +5,7 @@ use App\Enums\TargetType; use App\Models\Label; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -14,6 +15,7 @@ class LabelTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/Mutations/ChangeGlobalRoleTest.php b/tests/Feature/GraphQL/Mutations/ChangeGlobalRoleTest.php index 7d6a6c4438..623189b134 100644 --- a/tests/Feature/GraphQL/Mutations/ChangeGlobalRoleTest.php +++ b/tests/Feature/GraphQL/Mutations/ChangeGlobalRoleTest.php @@ -4,12 +4,14 @@ use App\Enums\GlobalRole; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; use Tests\Traits\CreatesUsers; class ChangeGlobalRoleTest extends TestCase { use CreatesUsers; + use DatabaseTransactions; /** * @var array diff --git a/tests/Feature/GraphQL/Mutations/ChangeProjectRoleTest.php b/tests/Feature/GraphQL/Mutations/ChangeProjectRoleTest.php index 9d2246126e..ed1793cc2b 100644 --- a/tests/Feature/GraphQL/Mutations/ChangeProjectRoleTest.php +++ b/tests/Feature/GraphQL/Mutations/ChangeProjectRoleTest.php @@ -5,6 +5,7 @@ use App\Enums\ProjectRole; use App\Models\Project; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; use Tests\Traits\CreatesProjects; use Tests\Traits\CreatesUsers; @@ -13,6 +14,7 @@ class ChangeProjectRoleTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/Mutations/CreateGlobalInvitationTest.php b/tests/Feature/GraphQL/Mutations/CreateGlobalInvitationTest.php index 8a37d72f6e..4db2ff3cae 100644 --- a/tests/Feature/GraphQL/Mutations/CreateGlobalInvitationTest.php +++ b/tests/Feature/GraphQL/Mutations/CreateGlobalInvitationTest.php @@ -6,7 +6,7 @@ use App\Mail\InvitedToCdash; use App\Models\GlobalInvitation; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseTruncation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Mail; use PHPUnit\Framework\Attributes\DataProvider; @@ -16,7 +16,7 @@ class CreateGlobalInvitationTest extends TestCase { use CreatesUsers; - use DatabaseTruncation; + use DatabaseTransactions; /** * @var array diff --git a/tests/Feature/GraphQL/Mutations/CreateProjectTest.php b/tests/Feature/GraphQL/Mutations/CreateProjectTest.php index d98526c0c0..b075cb0137 100644 --- a/tests/Feature/GraphQL/Mutations/CreateProjectTest.php +++ b/tests/Feature/GraphQL/Mutations/CreateProjectTest.php @@ -4,6 +4,7 @@ use App\Models\Project; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Config; use Illuminate\Support\Str; use PHPUnit\Framework\Attributes\DataProvider; @@ -13,6 +14,7 @@ class CreateProjectTest extends TestCase { use CreatesUsers; + use DatabaseTransactions; /** * @var array diff --git a/tests/Feature/GraphQL/Mutations/InviteToProjectTest.php b/tests/Feature/GraphQL/Mutations/InviteToProjectTest.php index 28ec91450e..9c21a2ec66 100644 --- a/tests/Feature/GraphQL/Mutations/InviteToProjectTest.php +++ b/tests/Feature/GraphQL/Mutations/InviteToProjectTest.php @@ -6,6 +6,7 @@ use App\Mail\InvitedToProject; use App\Models\Project; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Mail; use PHPUnit\Framework\Attributes\DataProvider; @@ -17,6 +18,7 @@ class InviteToProjectTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/Mutations/JoinProjectTest.php b/tests/Feature/GraphQL/Mutations/JoinProjectTest.php index 1574c29ccd..2dbba48d5a 100644 --- a/tests/Feature/GraphQL/Mutations/JoinProjectTest.php +++ b/tests/Feature/GraphQL/Mutations/JoinProjectTest.php @@ -4,6 +4,7 @@ use App\Models\Project; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; use Tests\Traits\CreatesProjects; use Tests\Traits\CreatesUsers; @@ -12,6 +13,7 @@ class JoinProjectTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private ?Project $project = null; diff --git a/tests/Feature/GraphQL/Mutations/RemoveProjectUserTest.php b/tests/Feature/GraphQL/Mutations/RemoveProjectUserTest.php index ae29f9a28b..087674551e 100644 --- a/tests/Feature/GraphQL/Mutations/RemoveProjectUserTest.php +++ b/tests/Feature/GraphQL/Mutations/RemoveProjectUserTest.php @@ -4,6 +4,7 @@ use App\Models\Project; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Config; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -13,6 +14,7 @@ class RemoveProjectUserTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/Mutations/RemoveUserTest.php b/tests/Feature/GraphQL/Mutations/RemoveUserTest.php index 11034f6878..6cfdcb6848 100644 --- a/tests/Feature/GraphQL/Mutations/RemoveUserTest.php +++ b/tests/Feature/GraphQL/Mutations/RemoveUserTest.php @@ -3,12 +3,14 @@ namespace Tests\Feature\GraphQL\Mutations; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; use Tests\Traits\CreatesUsers; class RemoveUserTest extends TestCase { use CreatesUsers; + use DatabaseTransactions; /** * @var array diff --git a/tests/Feature/GraphQL/Mutations/RevokeGlobalInvitationTest.php b/tests/Feature/GraphQL/Mutations/RevokeGlobalInvitationTest.php index 93f7786544..00429419cb 100644 --- a/tests/Feature/GraphQL/Mutations/RevokeGlobalInvitationTest.php +++ b/tests/Feature/GraphQL/Mutations/RevokeGlobalInvitationTest.php @@ -5,6 +5,7 @@ use App\Enums\GlobalRole; use App\Models\GlobalInvitation; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; @@ -14,6 +15,7 @@ class RevokeGlobalInvitationTest extends TestCase { use CreatesUsers; + use DatabaseTransactions; /** * @var array diff --git a/tests/Feature/GraphQL/Mutations/RevokeProjectInvitationTest.php b/tests/Feature/GraphQL/Mutations/RevokeProjectInvitationTest.php index 62ba3aebd7..b28c4c50ce 100644 --- a/tests/Feature/GraphQL/Mutations/RevokeProjectInvitationTest.php +++ b/tests/Feature/GraphQL/Mutations/RevokeProjectInvitationTest.php @@ -6,6 +6,7 @@ use App\Models\Project; use App\Models\ProjectInvitation; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -15,6 +16,7 @@ class RevokeProjectInvitationTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/Mutations/UpdateSiteDescriptionTest.php b/tests/Feature/GraphQL/Mutations/UpdateSiteDescriptionTest.php index 593366fb99..279f1668cc 100644 --- a/tests/Feature/GraphQL/Mutations/UpdateSiteDescriptionTest.php +++ b/tests/Feature/GraphQL/Mutations/UpdateSiteDescriptionTest.php @@ -4,6 +4,7 @@ use App\Models\Site; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use Tests\TestCase; @@ -14,6 +15,7 @@ class UpdateSiteDescriptionTest extends TestCase { use CreatesSites; use CreatesUsers; + use DatabaseTransactions; private Site $site; diff --git a/tests/Feature/GraphQL/NoteTypeTest.php b/tests/Feature/GraphQL/NoteTypeTest.php index 7120d0515a..02302d2f7d 100644 --- a/tests/Feature/GraphQL/NoteTypeTest.php +++ b/tests/Feature/GraphQL/NoteTypeTest.php @@ -4,6 +4,7 @@ use App\Models\Note; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use Random\RandomException; use Tests\TestCase; @@ -14,6 +15,7 @@ class NoteTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $public_project; private Project $private_project; diff --git a/tests/Feature/GraphQL/ProjectInvitationTypeTest.php b/tests/Feature/GraphQL/ProjectInvitationTypeTest.php index 9b2acbe305..19dd1e5465 100644 --- a/tests/Feature/GraphQL/ProjectInvitationTypeTest.php +++ b/tests/Feature/GraphQL/ProjectInvitationTypeTest.php @@ -6,6 +6,7 @@ use App\Models\Project; use App\Models\ProjectInvitation; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -15,6 +16,7 @@ class ProjectInvitationTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; private User $normalUser; diff --git a/tests/Feature/GraphQL/ProjectTypeTest.php b/tests/Feature/GraphQL/ProjectTypeTest.php index aad55f4cb6..f00b9a21fb 100644 --- a/tests/Feature/GraphQL/ProjectTypeTest.php +++ b/tests/Feature/GraphQL/ProjectTypeTest.php @@ -4,7 +4,7 @@ use App\Models\Project; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseTruncation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use PHPUnit\Framework\Attributes\DataProvider; use Tests\TestCase; @@ -15,7 +15,7 @@ class ProjectTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; - use DatabaseTruncation; + use DatabaseTransactions; /** * @var array diff --git a/tests/Feature/GraphQL/QueryTypeTest.php b/tests/Feature/GraphQL/QueryTypeTest.php index 2af5bdef84..2bf2f364f5 100644 --- a/tests/Feature/GraphQL/QueryTypeTest.php +++ b/tests/Feature/GraphQL/QueryTypeTest.php @@ -3,12 +3,14 @@ namespace Tests\Feature\GraphQL; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; use Tests\Traits\CreatesUsers; class QueryTypeTest extends TestCase { use CreatesUsers; + use DatabaseTransactions; /** @var array */ private array $users = []; diff --git a/tests/Feature/GraphQL/SiteTypeTest.php b/tests/Feature/GraphQL/SiteTypeTest.php index 64ac355c40..77ce8af2a0 100644 --- a/tests/Feature/GraphQL/SiteTypeTest.php +++ b/tests/Feature/GraphQL/SiteTypeTest.php @@ -5,7 +5,7 @@ use App\Models\Project; use App\Models\Site; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseTruncation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use PHPUnit\Framework\Attributes\DataProvider; @@ -19,7 +19,7 @@ class SiteTypeTest extends TestCase use CreatesProjects; use CreatesSites; use CreatesUsers; - use DatabaseTruncation; + use DatabaseTransactions; /** * @var array @@ -526,15 +526,18 @@ public function testMultipleSiteInformation(): void 'name' => 'site1', ]); - $this->sites['site1']->information()->createMany([ + $this->sites['site1']->information()->forceCreateMany([ [ 'description' => 'site 1 information 1', + 'timestamp' => Carbon::now()->subHour(), ], [ 'description' => 'site 1 information 2', + 'timestamp' => Carbon::now()->subMinute(), ], [ 'description' => 'site 1 information 3', + 'timestamp' => Carbon::now(), ], ]); diff --git a/tests/Feature/GraphQL/TargetTypeTest.php b/tests/Feature/GraphQL/TargetTypeTest.php index 6a12928cde..6c8f9cf578 100644 --- a/tests/Feature/GraphQL/TargetTypeTest.php +++ b/tests/Feature/GraphQL/TargetTypeTest.php @@ -8,6 +8,7 @@ use App\Models\BuildCommand; use App\Models\Project; use App\Models\Target; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use PHPUnit\Framework\Attributes\DataProvider; @@ -19,6 +20,7 @@ class TargetTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/TestMeasurementTypeTest.php b/tests/Feature/GraphQL/TestMeasurementTypeTest.php index 7eecfcb4dc..9055bc84ed 100644 --- a/tests/Feature/GraphQL/TestMeasurementTypeTest.php +++ b/tests/Feature/GraphQL/TestMeasurementTypeTest.php @@ -4,6 +4,7 @@ use App\Models\Project; use App\Models\TestOutput; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use Random\RandomException; use Tests\TestCase; @@ -14,6 +15,7 @@ class TestMeasurementTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; private TestOutput $test_output; diff --git a/tests/Feature/GraphQL/TestTypeTest.php b/tests/Feature/GraphQL/TestTypeTest.php index 39e54b81ab..61900afdf8 100644 --- a/tests/Feature/GraphQL/TestTypeTest.php +++ b/tests/Feature/GraphQL/TestTypeTest.php @@ -4,6 +4,7 @@ use App\Models\Project; use App\Models\TestOutput; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use PHPUnit\Framework\Attributes\DataProvider; use Random\RandomException; @@ -15,6 +16,7 @@ class TestTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; private TestOutput $test_output; diff --git a/tests/Feature/GraphQL/UpdateFileTypeTest.php b/tests/Feature/GraphQL/UpdateFileTypeTest.php index 948d332169..8b231c927c 100644 --- a/tests/Feature/GraphQL/UpdateFileTypeTest.php +++ b/tests/Feature/GraphQL/UpdateFileTypeTest.php @@ -6,6 +6,7 @@ use App\Models\BuildUpdate; use App\Models\BuildUpdateFile; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -15,6 +16,7 @@ class UpdateFileTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/UpdateTypeTest.php b/tests/Feature/GraphQL/UpdateTypeTest.php index d0b4fa96f1..9c06163478 100644 --- a/tests/Feature/GraphQL/UpdateTypeTest.php +++ b/tests/Feature/GraphQL/UpdateTypeTest.php @@ -5,6 +5,7 @@ use App\Models\Build; use App\Models\BuildUpdate; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -14,6 +15,7 @@ class UpdateTypeTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/GraphQL/UserTypeTest.php b/tests/Feature/GraphQL/UserTypeTest.php index 2f912eb806..a9e71f9cdb 100644 --- a/tests/Feature/GraphQL/UserTypeTest.php +++ b/tests/Feature/GraphQL/UserTypeTest.php @@ -3,12 +3,14 @@ namespace Tests\Feature\GraphQL; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; use Tests\Traits\CreatesUsers; class UserTypeTest extends TestCase { use CreatesUsers; + use DatabaseTransactions; private User $normalUser; private User $adminUser; diff --git a/tests/Feature/Jobs/NotifyExpiringAuthTokensTest.php b/tests/Feature/Jobs/NotifyExpiringAuthTokensTest.php index a6f09362db..687fe61f0f 100644 --- a/tests/Feature/Jobs/NotifyExpiringAuthTokensTest.php +++ b/tests/Feature/Jobs/NotifyExpiringAuthTokensTest.php @@ -5,7 +5,7 @@ use App\Jobs\NotifyExpiringAuthTokens; use App\Mail\AuthTokenExpiring; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseTruncation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Str; @@ -15,7 +15,7 @@ class NotifyExpiringAuthTokensTest extends TestCase { use CreatesUsers; - use DatabaseTruncation; + use DatabaseTransactions; protected User $user; diff --git a/tests/Feature/Jobs/PruneAuthTokensTest.php b/tests/Feature/Jobs/PruneAuthTokensTest.php index e41da9cca7..e0f41c3aaa 100644 --- a/tests/Feature/Jobs/PruneAuthTokensTest.php +++ b/tests/Feature/Jobs/PruneAuthTokensTest.php @@ -6,7 +6,7 @@ use App\Mail\AuthTokenExpired; use App\Models\AuthToken; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseTruncation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Str; @@ -16,7 +16,7 @@ class PruneAuthTokensTest extends TestCase { use CreatesUsers; - use DatabaseTruncation; + use DatabaseTransactions; protected User $user; diff --git a/tests/Feature/Jobs/PruneBuildsTest.php b/tests/Feature/Jobs/PruneBuildsTest.php index 9c991257ab..981b33cc7b 100644 --- a/tests/Feature/Jobs/PruneBuildsTest.php +++ b/tests/Feature/Jobs/PruneBuildsTest.php @@ -4,6 +4,7 @@ use App\Jobs\PruneBuilds; use App\Models\Project; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use Tests\TestCase; @@ -16,6 +17,7 @@ class PruneBuildsTest extends TestCase { use CreatesProjects; + use DatabaseTransactions; protected Project $project; diff --git a/tests/Feature/Jobs/PruneEmailsTest.php b/tests/Feature/Jobs/PruneEmailsTest.php index 5914b6b893..654c58e989 100644 --- a/tests/Feature/Jobs/PruneEmailsTest.php +++ b/tests/Feature/Jobs/PruneEmailsTest.php @@ -5,6 +5,7 @@ use App\Jobs\PruneEmails; use App\Models\Project; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use Tests\TestCase; @@ -15,6 +16,7 @@ class PruneEmailsTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; protected Project $project; protected User $user; diff --git a/tests/Feature/Jobs/PruneJobsTest.php b/tests/Feature/Jobs/PruneJobsTest.php index f47db7d0ae..9fc32b0731 100644 --- a/tests/Feature/Jobs/PruneJobsTest.php +++ b/tests/Feature/Jobs/PruneJobsTest.php @@ -4,12 +4,15 @@ use App\Jobs\PruneJobs; use App\Models\SuccessfulJob; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use Tests\TestCase; class PruneJobsTest extends TestCase { + use DatabaseTransactions; + /** * Changing the config is difficult since multiple processes are involved. * Instead, we just rely upon the default value of 48 hours. diff --git a/tests/Feature/Jobs/PruneUploadsTest.php b/tests/Feature/Jobs/PruneUploadsTest.php index df1dcb050e..a17aebd3d2 100644 --- a/tests/Feature/Jobs/PruneUploadsTest.php +++ b/tests/Feature/Jobs/PruneUploadsTest.php @@ -6,6 +6,7 @@ use App\Models\Build; use App\Models\Project; use App\Models\UploadFile; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; @@ -19,6 +20,7 @@ class PruneUploadsTest extends TestCase { use CreatesProjects; + use DatabaseTransactions; private Project $project; diff --git a/tests/Feature/LoginAndRegistration.php b/tests/Feature/LoginAndRegistration.php index e3fdbe6005..1b3351b949 100644 --- a/tests/Feature/LoginAndRegistration.php +++ b/tests/Feature/LoginAndRegistration.php @@ -4,6 +4,7 @@ use App\Listeners\Saml2Login as Saml2LoginListener; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\DB; @@ -23,6 +24,7 @@ class LoginAndRegistration extends TestCase { use CreatesUsers; + use DatabaseTransactions; protected static string $email = 'logintest@user.com'; protected static string $password = '54321'; diff --git a/tests/Feature/Mail/AuthTokenExpiredTest.php b/tests/Feature/Mail/AuthTokenExpiredTest.php index f1dda8f2fe..53acb74173 100644 --- a/tests/Feature/Mail/AuthTokenExpiredTest.php +++ b/tests/Feature/Mail/AuthTokenExpiredTest.php @@ -5,6 +5,7 @@ use App\Mail\AuthTokenExpired; use App\Models\AuthToken; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use Tests\TestCase; @@ -13,6 +14,7 @@ class AuthTokenExpiredTest extends TestCase { use CreatesUsers; + use DatabaseTransactions; protected User $user; diff --git a/tests/Feature/Mail/AuthTokenExpiringTest.php b/tests/Feature/Mail/AuthTokenExpiringTest.php index 7630c5dfe9..2b9f347955 100644 --- a/tests/Feature/Mail/AuthTokenExpiringTest.php +++ b/tests/Feature/Mail/AuthTokenExpiringTest.php @@ -5,6 +5,7 @@ use App\Mail\AuthTokenExpiring; use App\Models\AuthToken; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Str; use Tests\TestCase; @@ -13,6 +14,7 @@ class AuthTokenExpiringTest extends TestCase { use CreatesUsers; + use DatabaseTransactions; protected User $user; diff --git a/tests/Feature/Monitor.php b/tests/Feature/Monitor.php index fe471d6fd5..c5acf430ac 100644 --- a/tests/Feature/Monitor.php +++ b/tests/Feature/Monitor.php @@ -5,7 +5,7 @@ use App\Enums\ClassicPalette; use App\Enums\HighContrastPalette; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseTruncation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\URL; use LogicException; @@ -16,7 +16,7 @@ class Monitor extends TestCase { use CreatesUsers; - use DatabaseTruncation; + use DatabaseTransactions; protected User $normal_user; protected User $admin_user; diff --git a/tests/Feature/PasswordRotation.php b/tests/Feature/PasswordRotation.php index fa1b223bfd..6b451770d3 100644 --- a/tests/Feature/PasswordRotation.php +++ b/tests/Feature/PasswordRotation.php @@ -3,12 +3,15 @@ namespace Tests\Feature; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\URL; use Tests\TestCase; class PasswordRotation extends TestCase { + use DatabaseTransactions; + protected ?User $user; protected function setUp(): void diff --git a/tests/Feature/ProjectInvitationAcceptanceTest.php b/tests/Feature/ProjectInvitationAcceptanceTest.php index 90220ae1b4..ff44d4b17f 100644 --- a/tests/Feature/ProjectInvitationAcceptanceTest.php +++ b/tests/Feature/ProjectInvitationAcceptanceTest.php @@ -6,6 +6,7 @@ use App\Models\Project; use App\Models\ProjectInvitation; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -15,6 +16,7 @@ class ProjectInvitationAcceptanceTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; protected Project $project; @@ -35,13 +37,13 @@ protected function setUp(): void protected function tearDown(): void { - parent::tearDown(); - $this->project->delete(); foreach ($this->users as $user) { $user->delete(); } + + parent::tearDown(); } private function createInvitation(): ProjectInvitation diff --git a/tests/Feature/ProjectPermissions.php b/tests/Feature/ProjectPermissions.php index f3a9b3971b..0eae3c4b18 100644 --- a/tests/Feature/ProjectPermissions.php +++ b/tests/Feature/ProjectPermissions.php @@ -4,6 +4,7 @@ use App\Models\Project; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\URL; use Tests\TestCase; @@ -14,6 +15,7 @@ class ProjectPermissions extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; protected Project $public_project; protected Project $protected_project; diff --git a/tests/Feature/PurgeUnusedProjectsCommand.php b/tests/Feature/PurgeUnusedProjectsCommand.php index 2a3430ed53..f6226d85ac 100644 --- a/tests/Feature/PurgeUnusedProjectsCommand.php +++ b/tests/Feature/PurgeUnusedProjectsCommand.php @@ -4,7 +4,7 @@ use CDash\Model\Build; use CDash\Model\Project; -use Illuminate\Foundation\Testing\DatabaseTruncation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use Tests\TestCase; use Tests\Traits\CreatesProjects; @@ -12,7 +12,7 @@ class PurgeUnusedProjectsCommand extends TestCase { use CreatesProjects; - use DatabaseTruncation; + use DatabaseTransactions; private \App\Models\Project $project1; private \App\Models\Project $project2; diff --git a/tests/Feature/RemoteWorkers.php b/tests/Feature/RemoteWorkers.php index 32b737190d..26b9da7ded 100644 --- a/tests/Feature/RemoteWorkers.php +++ b/tests/Feature/RemoteWorkers.php @@ -2,6 +2,7 @@ namespace Tests\Feature; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Storage; @@ -10,6 +11,8 @@ class RemoteWorkers extends TestCase { + use DatabaseTransactions; + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/RouteAccessTest.php b/tests/Feature/RouteAccessTest.php index 3c46a5d098..48320b2bda 100644 --- a/tests/Feature/RouteAccessTest.php +++ b/tests/Feature/RouteAccessTest.php @@ -4,6 +4,7 @@ use App\Models\Project; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\URL; use LogicException; use Mockery\Exception\InvalidCountException; @@ -16,6 +17,7 @@ class RouteAccessTest extends TestCase { use CreatesProjects; use CreatesUsers; + use DatabaseTransactions; private User $normal_user; private User $admin_user; diff --git a/tests/Feature/Services/ProjectServiceTest.php b/tests/Feature/Services/ProjectServiceTest.php index caeba0a4eb..b5f46a2e6d 100644 --- a/tests/Feature/Services/ProjectServiceTest.php +++ b/tests/Feature/Services/ProjectServiceTest.php @@ -4,11 +4,14 @@ use App\Models\Project; use App\Services\ProjectService; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; use Tests\TestCase; class ProjectServiceTest extends TestCase { + use DatabaseTransactions; + protected ?Project $project = null; protected function setUp(): void @@ -18,9 +21,9 @@ protected function setUp(): void protected function tearDown(): void { - parent::tearDown(); - $this->project?->delete(); + + parent::tearDown(); } public function testCreatesDefaultBuildGroups(): void diff --git a/tests/Feature/SlowPageTest.php b/tests/Feature/SlowPageTest.php index 0b8b8d6f15..f85d42e3a3 100644 --- a/tests/Feature/SlowPageTest.php +++ b/tests/Feature/SlowPageTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Log; use Mockery; @@ -9,6 +10,8 @@ class SlowPageTest extends TestCase { + use DatabaseTransactions; + public function testSlowPageLogsWarning(): void { Log::shouldReceive('warning') diff --git a/tests/Feature/Traits/UpdatesSiteInformationTest.php b/tests/Feature/Traits/UpdatesSiteInformationTest.php index ade9c5f363..15536c8476 100644 --- a/tests/Feature/Traits/UpdatesSiteInformationTest.php +++ b/tests/Feature/Traits/UpdatesSiteInformationTest.php @@ -5,6 +5,7 @@ use App\Http\Submission\Traits\UpdatesSiteInformation; use App\Models\Site; use App\Models\SiteInformation; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Carbon; use Tests\TestCase; use Tests\Traits\CreatesSites; @@ -12,6 +13,7 @@ class UpdatesSiteInformationTest extends TestCase { use CreatesSites; + use DatabaseTransactions; use UpdatesSiteInformation; private Site $site; diff --git a/tests/Feature/UserCommand.php b/tests/Feature/UserCommand.php index 7b49334a65..16e87ed98a 100644 --- a/tests/Feature/UserCommand.php +++ b/tests/Feature/UserCommand.php @@ -3,11 +3,14 @@ namespace Tests\Feature; use App\Models\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Artisan; use Tests\TestCase; class UserCommand extends TestCase { + use DatabaseTransactions; + protected $user; /**