File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
src/Symfony/Component/Mime Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ public function addFrom(...$addresses)
121
121
*/
122
122
public function from (...$ addresses )
123
123
{
124
+ if (!$ addresses ) {
125
+ throw new LogicException (sprintf ('"from()" must be called with at least one address. ' ));
126
+ }
127
+
124
128
return $ this ->setListAddressHeaderBody ('From ' , $ addresses );
125
129
}
126
130
Original file line number Diff line number Diff line change 15
15
use PHPUnit \Framework \TestCase ;
16
16
use Symfony \Component \Mime \Address ;
17
17
use Symfony \Component \Mime \Email ;
18
+ use Symfony \Component \Mime \Exception \LogicException ;
18
19
use Symfony \Component \Mime \Part \DataPart ;
19
20
use Symfony \Component \Mime \Part \Multipart \AlternativePart ;
20
21
use Symfony \Component \Mime \Part \Multipart \MixedPart ;
@@ -62,6 +63,13 @@ public function testSender()
62
63
$ this ->assertSame ($ fabien , $ e ->getSender ());
63
64
}
64
65
66
+ public function testFromWithNoAddress ()
67
+ {
68
+ $ e = new Email ();
69
+ $ this ->expectException (LogicException::class);
70
+ $ e ->from ();
71
+ }
72
+
65
73
public function testFrom ()
66
74
{
67
75
$ e = new Email ();
You can’t perform that action at this time.
0 commit comments