File tree 2 files changed +30
-0
lines changed
src/Symfony/Component/Mime
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,20 @@ public function asInline(): static
89
89
return $ this ->setDisposition ('inline ' );
90
90
}
91
91
92
+ /**
93
+ * @return $this
94
+ */
95
+ public function setContentId (string $ cid ): static
96
+ {
97
+ if (!str_contains ($ cid , '@ ' )) {
98
+ throw new InvalidArgumentException (sprintf ('Invalid cid "%s". ' , $ cid ));
99
+ }
100
+
101
+ $ this ->cid = $ cid ;
102
+
103
+ return $ this ;
104
+ }
105
+
92
106
public function getContentId (): string
93
107
{
94
108
return $ this ->cid ?: $ this ->cid = $ this ->generateContentId ();
Original file line number Diff line number Diff line change @@ -166,6 +166,22 @@ public function testHasContentId()
166
166
$ this ->assertTrue ($ p ->hasContentId ());
167
167
}
168
168
169
+ public function testSetContentId ()
170
+ {
171
+ $ p = new DataPart ('content ' );
172
+ $ p ->setContentId ('test@test ' );
173
+ $ this ->assertTrue ($ p ->hasContentId ());
174
+ $ this ->assertSame ('test@test ' , $ p ->getContentId ());
175
+ }
176
+
177
+ public function testSetContentIdInvalid ()
178
+ {
179
+ $ this ->expectException (InvalidArgumentException::class);
180
+
181
+ $ p = new DataPart ('content ' );
182
+ $ p ->setContentId ('test ' );
183
+ }
184
+
169
185
public function testGetFilename ()
170
186
{
171
187
$ p = new DataPart ('content ' , null );
You can’t perform that action at this time.
0 commit comments