create(); $this->assertInstanceOf(RemoteEmail::class, $remoteEmail); $this->assertIsArray($remoteEmail->to); $this->assertIsString($remoteEmail->from_email); } /** @test */ public function it_has_correct_fillable_attributes() { $timestamp = now(); $remoteEmailData = [ 'message_id' => 'remote_123', 'subject' => 'Remote Email Subject', 'from_name' => 'Remote Sender', 'from_email' => 'remote@example.com', 'to' => ['recipient@example.com'], 'body_html' => '

HTML content

', 'body_text' => 'Text content', 'is_seen' => false, 'timestamp' => $timestamp, ]; $remoteEmail = RemoteEmail::create($remoteEmailData); foreach ($remoteEmailData as $key => $value) { if ($key === 'timestamp') { $this->assertInstanceOf(Carbon::class, $remoteEmail->$key); $this->assertEquals($timestamp->format('Y-m-d H:i:s'), $remoteEmail->$key->format('Y-m-d H:i:s')); } else { $this->assertEquals($value, $remoteEmail->$key); } } } /** @test */ public function it_casts_to_field_to_array() { $to = ['test1@example.com', 'test2@example.com']; $remoteEmail = RemoteEmail::factory()->create(['to' => $to]); $this->assertIsArray($remoteEmail->to); $this->assertEquals($to, $remoteEmail->to); } /** @test */ public function it_casts_timestamp_to_datetime() { $timestamp = now(); $remoteEmail = RemoteEmail::factory()->create(['timestamp' => $timestamp]); $this->assertInstanceOf(Carbon::class, $remoteEmail->timestamp); $this->assertEquals($timestamp->format('Y-m-d H:i:s'), $remoteEmail->timestamp->format('Y-m-d H:i:s')); } }