From 3c79d26c4cc6c0a93982bbe0694f3d0807455047 Mon Sep 17 00:00:00 2001 From: Tjardo Date: Sat, 24 Feb 2024 20:33:11 +0100 Subject: [PATCH] Update tests --- tests/TestCase.php | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index e0e52ec..16ebee7 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,9 @@ namespace Label84\MailViewer\Tests; +use Illuminate\Database\Schema\Blueprint; use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Support\Facades\Schema; use Label84\MailViewer\MailViewerServiceProvider; class TestCase extends \Orchestra\Testbench\TestCase @@ -13,7 +15,7 @@ public function setUp(): void { parent::setUp(); - $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + $this->setUpDatabase(); } protected function getPackageProviders($app): array @@ -25,8 +27,31 @@ protected function getPackageProviders($app): array protected function getEnvironmentSetUp($app): void { - include_once __DIR__.'/../database/migrations/create_mail_viewer_items_table.php.stub'; + config()->set('mailviewer.database_connection', 'sqlite'); + config()->set('database.default', 'sqlite'); + config()->set('database.connections.sqlite', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + ]); + } + + protected function setUpDatabase() + { + Schema::create(config('mailviewer.table_name'), function (Blueprint $table) { + $table->uuid('uuid')->primary(); + + $table->string('event_type'); + $table->string('mailer'); + + $table->text('headers')->nullable(); + $table->text('recipients'); + + $table->string('notification')->nullable(); + + $table->string('subject')->nullable(); + $table->text('body')->nullable(); - (new \CreateMailViewerItemsTable())->up(); + $table->string('sent_at'); + }); } }