From 1c3bccd1f8cd94eddfd1e1b65824d7a24d87f0db Mon Sep 17 00:00:00 2001 From: TheDoctor0 Date: Tue, 4 Apr 2023 10:33:14 +0200 Subject: [PATCH] Add subject to email model. --- database/factories/EmailFactory.php | 1 + .../add_subject_to_emails_table.php.stub | 32 +++++++++++++++++++ src/App/Models/Email.php | 2 ++ src/Implementations/SesMailer.php | 3 +- src/LaravelSesEventManagerServiceProvider.php | 1 + .../EventManagerBounceTest.php | 3 +- .../Implementations/EventManagerClickTest.php | 3 +- .../EventManagerComplaintTest.php | 3 +- .../EventManagerDeliveryDelayTest.php | 3 +- .../EventManagerDeliveryTest.php | 3 +- .../Implementations/EventManagerOpenTest.php | 3 +- .../EventManagerRejectTest.php | 3 +- .../EventManagerRenderingFailureTest.php | 3 +- .../Implementations/EventManagerSendTest.php | 3 +- .../EventManagerSubscriptionTest.php | 3 +- tests/Unit/Models/EmailBounceTest.php | 3 +- tests/Unit/Models/EmailClickTest.php | 3 +- tests/Unit/Models/EmailComplaintTest.php | 3 +- tests/Unit/Models/EmailDeliveryDelayTest.php | 3 +- tests/Unit/Models/EmailDeliveryTest.php | 3 +- tests/Unit/Models/EmailOpenTest.php | 3 +- tests/Unit/Models/EmailRejectTest.php | 3 +- .../Unit/Models/EmailRenderingFailureTest.php | 3 +- tests/Unit/Models/EmailSendTest.php | 3 +- tests/Unit/Models/EmailSubscriptionTest.php | 3 +- tests/Unit/Models/EmailTest.php | 3 +- 26 files changed, 80 insertions(+), 22 deletions(-) create mode 100644 database/migrations/add_subject_to_emails_table.php.stub diff --git a/database/factories/EmailFactory.php b/database/factories/EmailFactory.php index f2fc4ea..f73d6a6 100644 --- a/database/factories/EmailFactory.php +++ b/database/factories/EmailFactory.php @@ -28,6 +28,7 @@ public function definition() 'message_id' => $this->faker->uuid(), 'email' => $this->faker->unique()->safeEmail(), 'name' => $this->faker->name(), + 'subject' => $this->faker->sentence(), ]; } diff --git a/database/migrations/add_subject_to_emails_table.php.stub b/database/migrations/add_subject_to_emails_table.php.stub new file mode 100644 index 0000000..f5ceab7 --- /dev/null +++ b/database/migrations/add_subject_to_emails_table.php.stub @@ -0,0 +1,32 @@ +string('subject')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table(config('laravel-ses-event-manager.database_name_prefix') . '_emails', function (Blueprint $table) { + $table->dropColumn('subject'); + }); + } +}; diff --git a/src/App/Models/Email.php b/src/App/Models/Email.php index 6b27586..b1d211f 100644 --- a/src/App/Models/Email.php +++ b/src/App/Models/Email.php @@ -43,6 +43,7 @@ protected static function newFactory() 'message_id', 'email', 'name', + 'subject', 'has_send', 'has_rendering_failure', 'has_reject', @@ -64,6 +65,7 @@ protected static function newFactory() 'message_id' => 'string', 'email' => 'string', 'name' => 'string', + 'subject' => 'string', 'has_send' => 'boolean', 'has_rendering_failure' => 'boolean', 'has_reject' => 'boolean', diff --git a/src/Implementations/SesMailer.php b/src/Implementations/SesMailer.php index 4989a4f..080a905 100644 --- a/src/Implementations/SesMailer.php +++ b/src/Implementations/SesMailer.php @@ -134,7 +134,7 @@ public function isMessageSent($result): bool } /** - * Save the email in the databse. + * Save the email in the database. * * @return void */ @@ -149,6 +149,7 @@ public function createEmailRecord($result): void 'message_id' => $result->getOriginalMessage()->getHeaders()->get('X-SES-Message-ID')->getValue(), 'email' => current($result->getOriginalMessage()->getTo())->getAddress(), 'name' => current($result->getOriginalMessage()->getTo())->getName(), + 'subject' => $result->getOriginalMessage()->getSubject(), ]); } } diff --git a/src/LaravelSesEventManagerServiceProvider.php b/src/LaravelSesEventManagerServiceProvider.php index ba9337a..5660f06 100644 --- a/src/LaravelSesEventManagerServiceProvider.php +++ b/src/LaravelSesEventManagerServiceProvider.php @@ -90,6 +90,7 @@ protected function bootForConsole(): void __DIR__.'/../database/migrations/create_email_rendering_failures_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', now()->addSeconds(8)->timestamp).'_create_'.config('laravel-ses-event-manager.database_name_prefix').'_email_rendering_failures_table.php'), __DIR__.'/../database/migrations/create_email_delivery_delays_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', now()->addSeconds(9)->timestamp).'_create_'.config('laravel-ses-event-manager.database_name_prefix').'_email_delivery_delays_table.php'), __DIR__.'/../database/migrations/create_email_subscriptions_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', now()->addSeconds(10)->timestamp).'_create_'.config('laravel-ses-event-manager.database_name_prefix').'_email_subscriptions_table.php'), + __DIR__.'/../database/migrations/add_subject_to_emails_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', now()->addSeconds(11)->timestamp).'_create_'.config('laravel-ses-event-manager.database_name_prefix').'_add_subject_to_emails_table.php'), ], self::PREFIX.'-migrations'); } diff --git a/tests/Feature/Implementations/EventManagerBounceTest.php b/tests/Feature/Implementations/EventManagerBounceTest.php index c46df14..a0605d1 100644 --- a/tests/Feature/Implementations/EventManagerBounceTest.php +++ b/tests/Feature/Implementations/EventManagerBounceTest.php @@ -25,6 +25,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_bounces_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; $this->emailTable = config('laravel-ses-event-manager.database_name_prefix').'_emails'; $this->bounceTable = config('laravel-ses-event-manager.database_name_prefix').'_email_bounces'; @@ -35,7 +36,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Feature/Implementations/EventManagerClickTest.php b/tests/Feature/Implementations/EventManagerClickTest.php index b6d8318..f059f69 100644 --- a/tests/Feature/Implementations/EventManagerClickTest.php +++ b/tests/Feature/Implementations/EventManagerClickTest.php @@ -25,6 +25,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_clicks_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; $this->emailTable = config('laravel-ses-event-manager.database_name_prefix').'_emails'; $this->clickTable = config('laravel-ses-event-manager.database_name_prefix').'_email_clicks'; @@ -35,7 +36,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Feature/Implementations/EventManagerComplaintTest.php b/tests/Feature/Implementations/EventManagerComplaintTest.php index f17e7fb..5f1ed04 100644 --- a/tests/Feature/Implementations/EventManagerComplaintTest.php +++ b/tests/Feature/Implementations/EventManagerComplaintTest.php @@ -25,6 +25,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_complaints_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; $this->emailTable = config('laravel-ses-event-manager.database_name_prefix').'_emails'; $this->complaintTable = config('laravel-ses-event-manager.database_name_prefix').'_email_complaints'; @@ -35,7 +36,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Feature/Implementations/EventManagerDeliveryDelayTest.php b/tests/Feature/Implementations/EventManagerDeliveryDelayTest.php index e3c44a3..194556b 100644 --- a/tests/Feature/Implementations/EventManagerDeliveryDelayTest.php +++ b/tests/Feature/Implementations/EventManagerDeliveryDelayTest.php @@ -25,6 +25,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_delivery_delays_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; $this->emailTable = config('laravel-ses-event-manager.database_name_prefix').'_emails'; $this->delayTable = config('laravel-ses-event-manager.database_name_prefix').'_email_delivery_delays'; @@ -35,7 +36,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Feature/Implementations/EventManagerDeliveryTest.php b/tests/Feature/Implementations/EventManagerDeliveryTest.php index bbfa670..f83c287 100644 --- a/tests/Feature/Implementations/EventManagerDeliveryTest.php +++ b/tests/Feature/Implementations/EventManagerDeliveryTest.php @@ -25,6 +25,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_deliveries_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; $this->emailTable = config('laravel-ses-event-manager.database_name_prefix').'_emails'; $this->deliveryTable = config('laravel-ses-event-manager.database_name_prefix').'_email_deliveries'; @@ -35,7 +36,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Feature/Implementations/EventManagerOpenTest.php b/tests/Feature/Implementations/EventManagerOpenTest.php index 3be549f..f76d785 100644 --- a/tests/Feature/Implementations/EventManagerOpenTest.php +++ b/tests/Feature/Implementations/EventManagerOpenTest.php @@ -25,6 +25,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_opens_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; $this->emailTable = config('laravel-ses-event-manager.database_name_prefix').'_emails'; $this->openTable = config('laravel-ses-event-manager.database_name_prefix').'_email_opens'; @@ -35,7 +36,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Feature/Implementations/EventManagerRejectTest.php b/tests/Feature/Implementations/EventManagerRejectTest.php index 7035453..4ed2f40 100644 --- a/tests/Feature/Implementations/EventManagerRejectTest.php +++ b/tests/Feature/Implementations/EventManagerRejectTest.php @@ -25,6 +25,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_rejects_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; $this->emailTable = config('laravel-ses-event-manager.database_name_prefix').'_emails'; $this->rejectTable = config('laravel-ses-event-manager.database_name_prefix').'_email_rejects'; @@ -35,7 +36,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Feature/Implementations/EventManagerRenderingFailureTest.php b/tests/Feature/Implementations/EventManagerRenderingFailureTest.php index 0a66ef1..239b7a1 100644 --- a/tests/Feature/Implementations/EventManagerRenderingFailureTest.php +++ b/tests/Feature/Implementations/EventManagerRenderingFailureTest.php @@ -25,6 +25,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_rendering_failures_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; $this->emailTable = config('laravel-ses-event-manager.database_name_prefix').'_emails'; $this->renderingTable = config('laravel-ses-event-manager.database_name_prefix').'_email_rendering_failures'; @@ -35,7 +36,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Feature/Implementations/EventManagerSendTest.php b/tests/Feature/Implementations/EventManagerSendTest.php index 9b465fc..942fdbb 100644 --- a/tests/Feature/Implementations/EventManagerSendTest.php +++ b/tests/Feature/Implementations/EventManagerSendTest.php @@ -25,6 +25,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_sends_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; $this->emailTable = config('laravel-ses-event-manager.database_name_prefix').'_emails'; $this->sendTable = config('laravel-ses-event-manager.database_name_prefix').'_email_sends'; @@ -35,7 +36,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Feature/Implementations/EventManagerSubscriptionTest.php b/tests/Feature/Implementations/EventManagerSubscriptionTest.php index 50295a6..9f7c3a9 100644 --- a/tests/Feature/Implementations/EventManagerSubscriptionTest.php +++ b/tests/Feature/Implementations/EventManagerSubscriptionTest.php @@ -25,6 +25,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_subscriptions_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; $this->emailTable = config('laravel-ses-event-manager.database_name_prefix').'_emails'; $this->subscriptionTable = config('laravel-ses-event-manager.database_name_prefix').'_email_subscriptions'; @@ -35,7 +36,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailBounceTest.php b/tests/Unit/Models/EmailBounceTest.php index 3df903c..4871ea5 100644 --- a/tests/Unit/Models/EmailBounceTest.php +++ b/tests/Unit/Models/EmailBounceTest.php @@ -19,6 +19,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_bounces_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -27,7 +28,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailClickTest.php b/tests/Unit/Models/EmailClickTest.php index 1dbe709..af51bc5 100644 --- a/tests/Unit/Models/EmailClickTest.php +++ b/tests/Unit/Models/EmailClickTest.php @@ -19,6 +19,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_clicks_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -27,7 +28,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailComplaintTest.php b/tests/Unit/Models/EmailComplaintTest.php index 68fa391..d584dc9 100644 --- a/tests/Unit/Models/EmailComplaintTest.php +++ b/tests/Unit/Models/EmailComplaintTest.php @@ -19,6 +19,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_complaints_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -27,7 +28,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailDeliveryDelayTest.php b/tests/Unit/Models/EmailDeliveryDelayTest.php index 312accd..c8b449b 100644 --- a/tests/Unit/Models/EmailDeliveryDelayTest.php +++ b/tests/Unit/Models/EmailDeliveryDelayTest.php @@ -19,6 +19,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_delivery_delays_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -27,7 +28,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailDeliveryTest.php b/tests/Unit/Models/EmailDeliveryTest.php index c6308f5..4aa9268 100644 --- a/tests/Unit/Models/EmailDeliveryTest.php +++ b/tests/Unit/Models/EmailDeliveryTest.php @@ -19,6 +19,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_deliveries_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -27,7 +28,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailOpenTest.php b/tests/Unit/Models/EmailOpenTest.php index db5dd6b..fedaa7f 100644 --- a/tests/Unit/Models/EmailOpenTest.php +++ b/tests/Unit/Models/EmailOpenTest.php @@ -19,6 +19,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_opens_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -27,7 +28,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailRejectTest.php b/tests/Unit/Models/EmailRejectTest.php index 01298e9..c070358 100644 --- a/tests/Unit/Models/EmailRejectTest.php +++ b/tests/Unit/Models/EmailRejectTest.php @@ -19,6 +19,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_rejects_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -27,7 +28,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailRenderingFailureTest.php b/tests/Unit/Models/EmailRenderingFailureTest.php index 4f71821..45ec255 100644 --- a/tests/Unit/Models/EmailRenderingFailureTest.php +++ b/tests/Unit/Models/EmailRenderingFailureTest.php @@ -19,6 +19,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_rendering_failures_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -27,7 +28,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailSendTest.php b/tests/Unit/Models/EmailSendTest.php index b4cf7d3..92694a9 100644 --- a/tests/Unit/Models/EmailSendTest.php +++ b/tests/Unit/Models/EmailSendTest.php @@ -19,6 +19,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_sends_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -27,7 +28,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailSubscriptionTest.php b/tests/Unit/Models/EmailSubscriptionTest.php index 75c5adb..5ef664b 100644 --- a/tests/Unit/Models/EmailSubscriptionTest.php +++ b/tests/Unit/Models/EmailSubscriptionTest.php @@ -19,6 +19,7 @@ protected function setUp(): void $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; $this->tables[] = include __DIR__.'/../../../database/migrations/create_email_subscriptions_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -27,7 +28,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); } diff --git a/tests/Unit/Models/EmailTest.php b/tests/Unit/Models/EmailTest.php index 99e84bd..a756300 100644 --- a/tests/Unit/Models/EmailTest.php +++ b/tests/Unit/Models/EmailTest.php @@ -17,6 +17,7 @@ protected function setUp(): void // Import the Emails Table class from the migration $this->tables = []; $this->tables[] = include __DIR__.'/../../../database/migrations/create_emails_table.php.stub'; + $this->tables[] = include __DIR__.'/../../../database/migrations/add_subject_to_emails_table.php.stub'; foreach ($this->tables as $table) { $table->up(); @@ -25,7 +26,7 @@ protected function setUp(): void protected function tearDown(): void { - foreach ($this->tables as $table) { + foreach (array_reverse($this->tables) as $table) { $table->down(); }