8000 Implement review comments · symfony/symfony@e34596b · GitHub
[go: up one dir, main page]

Skip to content

Commit e34596b

Browse files
committed
Implement review comments
1 parent fbc754b commit e34596b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Symfony/Component/Mime/Email.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ private function prepareParts(): ?array
479479
];
480480
$tmpMatches = [];
481481
foreach ($regexes as $regex) {
482-
preg_match_all('/' . $regex . '/i', $html, $tmpMatches);
482+
preg_match_all('/'.$regex.'/i', $html, $tmpMatches);
483483
$names = array_merge($names, $tmpMatches[2], $tmpMatches[3]);
484484
}
485485
$names = array_filter(array_unique($names));

src/Symfony/Component/Mime/Tests/EmailTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public function testGenerateBody()
329329
$generatedHtml = $parts[0]->getParts()[1];
330330
$this->assertStringContainsString('cid:'.$parts[1]->getContentId(), $generatedHtml->getBody());
331331

332-
$content = '<div background="cid:test.gif"></div>';
332+
$content = 'html content <img src="cid:test.gif">';
333333
$r = fopen('php://memory', 'r+', false);
334334
fwrite($r, $content);
335335
rewind($r);
@@ -343,6 +343,14 @@ public function testGenerateBody()
343343
$this->assertInstanceOf(RelatedPart::class, $body);
344344
// 2 parts only, not 3 (text + embedded image once)
345345
$this->assertCount(2, $parts = $body->getParts());
346+
$this->assertStringMatchesFormat('html content <img src=3D"cid:%s@symfony">', $parts[0]->bodyToString());
347+
348+
$e = (new Email())->from('me@example.com')->to('you@example.com');
349+
$e->html('<div background="cid:test.gif"></div>');
350+
$e->embed($image, 'test.gif');
351+
$body = $e->getBody();
352+
$this->assertInstanceOf(RelatedPart::class, $body);
353+
$this->assertCount(2, $parts = $body->getParts());
346354
$this->assertStringMatchesFormat('<div background=3D"cid:%s@symfony"></div>', $parts[0]->bodyToString());
347355
}
348356

0 commit comments

Comments
 (0)
0