@@ -695,4 +695,60 @@ public function testEmailsWithAttachmentsWhichAreAFileInstanceCanBeUnserialized(
695
695
$ this ->assertCount (1 , $ attachments );
696
696
$ this ->assertStringContainsString ('foo_bar_xyz_123 ' , $ attachments [0 ]->getBody ());
697
697
}
698
+
699
+ public function testInvalidBodyWithEmptyEmail ()
700
+ {
701
+ $ this ->expectException (\LogicException::class);
702
+ $ this ->expectExceptionMessage ('A message must have a text or an HTML part or attachments. ' );
703
+
704
+ (new Email ())->ensureValidity ();
705
+ }
706
+
707
+ public function testBodyWithTextIsValid ()
708
+ {
709
+ $ email = new Email ();
710
+
711
+
712
+ ->text ('foo ' );
713
+
714
+ $ email ->ensureValidity ();
715
+
716
+ $ this ->expectNotToPerformAssertions ();
717
+ }
718
+
719
+ public function testBodyWithHtmlIsValid ()
720
+ {
721
+ $ email = new Email ();
722
+
723
+
724
+ ->html ('foo ' );
725
+
726
+ $ email ->ensureValidity ();
727
+
728
+ $ this ->expectNotToPerformAssertions ();
729
+ }
730
+
731
+ public function testEmptyBodyWithAttachmentsIsValid ()
732
+ {
733
+ $ email = new Email ();
734
+
735
+
736
+ ->addPart (new DataPart ('foo ' ));
737
+
738
+ $ email ->ensureValidity ();
739
+
740
+ $ this ->expectNotToPerformAssertions ();
741
+ }
742
+
743
+ public function testSetBodyIsValid ()
744
+ {
745
+ $ email = new Email ();
746
+
747
+
748
+ ->setBody (new TextPart ('foo ' ));
749
+
750
+ $ email ->ensureValidity ();
751
+
752
+ $ this ->expectNotToPerformAssertions ();
753
+ }
698
754
}
0 commit comments