From 3e8e208c63528183648552c8a584dea8a4727348 Mon Sep 17 00:00:00 2001 From: JonasVHG <4658984+JonasVHG@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:29:48 +0100 Subject: [PATCH] use separate function setUpContact() --- .../EloquentIntegrationRepositoryTest.php | 81 ++++--------------- 1 file changed, 15 insertions(+), 66 deletions(-) diff --git a/tests/Domain/Integrations/Repositories/EloquentIntegrationRepositoryTest.php b/tests/Domain/Integrations/Repositories/EloquentIntegrationRepositoryTest.php index c3c7336f2..51d63ef36 100644 --- a/tests/Domain/Integrations/Repositories/EloquentIntegrationRepositoryTest.php +++ b/tests/Domain/Integrations/Repositories/EloquentIntegrationRepositoryTest.php @@ -724,7 +724,7 @@ public function test_get_drafts_by_type_and_between_months_old(): void ); } - private static function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): void + private function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): void { $wrongTypeId = Uuid::uuid4()->toString(); DB::table('integrations')->insert([ @@ -736,14 +736,7 @@ private static function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): vo 'status' => IntegrationStatus::Draft, 'created_at' => Carbon::now()->subMonths(14), ]); - DB::table('contacts')->insert([ - 'id' => Uuid::uuid4()->toString(), - 'integration_id' => $wrongTypeId, - 'email' => 'grote.smurf@example.com', - 'type' => ContactType::Technical->value, - 'first_name' => 'Grote', - 'last_name' => 'Smurf', - ]); + $this->setUpContact($wrongTypeId); $alreadyActiveId = Uuid::uuid4()->toString(); DB::table('integrations')->insert([ @@ -755,14 +748,7 @@ private static function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): vo 'status' => IntegrationStatus::Active, 'created_at' => Carbon::now()->subMonths(14), ]); - DB::table('contacts')->insert([ - 'id' => Uuid::uuid4()->toString(), - 'integration_id' => $alreadyActiveId, - 'email' => 'grote.smurf@example.com', - 'type' => ContactType::Technical->value, - 'first_name' => 'Grote', - 'last_name' => 'Smurf', - ]); + $this->setUpContact($alreadyActiveId); $noContactsId = Uuid::uuid4()->toString(); DB::table('integrations')->insert([ @@ -785,14 +771,7 @@ private static function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): vo 'status' => IntegrationStatus::Draft, 'created_at' => Carbon::now()->subMonths(11), ]); - DB::table('contacts')->insert([ - 'id' => Uuid::uuid4()->toString(), - 'integration_id' => $createdToRecentlyId, - 'email' => 'grote.smurf@example.com', - 'type' => ContactType::Technical->value, - 'first_name' => 'Grote', - 'last_name' => 'Smurf', - ]); + $this->setUpContact($createdToRecentlyId); $mailAlreadySentId = Uuid::uuid4()->toString(); DB::table('integrations')->insert([ @@ -809,14 +788,7 @@ private static function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): vo 'integration_id' => $mailAlreadySentId, 'template_name' => TemplateName::INTEGRATION_ACTIVATION_REMINDER->value, ]); - DB::table('contacts')->insert([ - 'id' => Uuid::uuid4()->toString(), - 'integration_id' => $mailAlreadySentId, - 'email' => 'grote.smurf@example.com', - 'type' => ContactType::Technical->value, - 'first_name' => 'Grote', - 'last_name' => 'Smurf', - ]); + $this->setUpContact($mailAlreadySentId); $tooOldId = Uuid::uuid4()->toString(); DB::table('integrations')->insert([ @@ -828,14 +800,7 @@ private static function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): vo 'status' => IntegrationStatus::Draft, 'created_at' => Carbon::now()->subMonths(50), ]); - DB::table('contacts')->insert([ - 'id' => Uuid::uuid4()->toString(), - 'integration_id' => $tooOldId, - 'email' => 'grote.smurf@example.com', - 'type' => ContactType::Technical->value, - 'first_name' => 'Grote', - 'last_name' => 'Smurf', - ]); + $this->setUpContact($tooOldId); $hasAdminHoldId = Uuid::uuid4()->toString(); DB::table('integrations')->insert([ @@ -847,14 +812,7 @@ private static function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): vo 'status' => IntegrationStatus::Draft, 'created_at' => Carbon::now()->subMonths(14), ]); - DB::table('contacts')->insert([ - 'id' => Uuid::uuid4()->toString(), - 'integration_id' => $hasAdminHoldId, - 'email' => 'grote.smurf@example.com', - 'type' => ContactType::Technical->value, - 'first_name' => 'Grote', - 'last_name' => 'Smurf', - ]); + $this->setUpContact($hasAdminHoldId); DB::table('admin_information')->insert([ 'id' => Uuid::uuid4()->toString(), 'integration_id' => $hasAdminHoldId, @@ -872,14 +830,7 @@ private static function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): vo 'status' => IntegrationStatus::Draft, 'created_at' => Carbon::now()->subMonths(14), ]); - DB::table('contacts')->insert([ - 'id' => Uuid::uuid4()->toString(), - 'integration_id' => $shouldBeSelectedId, - 'email' => 'grote.smurf@example.com', - 'type' => ContactType::Technical->value, - 'first_name' => 'Grote', - 'last_name' => 'Smurf', - ]); + $this->setUpContact($shouldBeSelectedId); $shouldAlsoBeSelectedId = Uuid::uuid4()->toString(); DB::table('integrations')->insert([ @@ -891,14 +842,7 @@ private static function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): vo 'status' => IntegrationStatus::Draft, 'created_at' => Carbon::now()->subMonths(15), ]); - DB::table('contacts')->insert([ - 'id' => Uuid::uuid4()->toString(), - 'integration_id' => $shouldAlsoBeSelectedId, - 'email' => 'grote.smurf@example.com', - 'type' => ContactType::Technical->value, - 'first_name' => 'Grote', - 'last_name' => 'Smurf', - ]); + $this->setUpContact($shouldAlsoBeSelectedId); $differentTypeOfMailId = Uuid::uuid4()->toString(); DB::table('integrations')->insert([ @@ -915,9 +859,14 @@ private static function setUpDatabaseForGetDraftsByTypeAndBetweenMonthsOld(): vo 'integration_id' => $differentTypeOfMailId, 'template_name' => TemplateName::INTEGRATION_CREATED->value, ]); + $this->setUpContact($differentTypeOfMailId); + } + + private function setUpContact(string $integrationId): void + { DB::table('contacts')->insert([ 'id' => Uuid::uuid4()->toString(), - 'integration_id' => $differentTypeOfMailId, + 'integration_id' => $integrationId, 'email' => 'grote.smurf@example.com', 'type' => ContactType::Technical->value, 'first_name' => 'Grote',