8000 Add unit test · symfony/symfony@d470523 · GitHub
[go: up one dir, main page]

Skip to content

Commit d470523

Browse files
BrokenSourceCodeBrokenSourceCode
authored andcommitted
Add unit test
1 parent e028d52 commit d470523

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,24 @@ public function testTextBodyAcceptedTypes()
458458
$email->text($contents);
459459
$this->assertSame($contents, $email->getTextBody());
460460
}
461+
462+
public function testBodyCache()
463+
{
464+
$email = new Email();
465+
$email->from('fabien@symfony.com');
466+
$email->to('fabien@symfony.com');
467+
$email->text('foo');
468+
$body1 = $email->getBody();
469+
$body2 = $email->getBody();
470+
$this->assertSame($body1, $body2, "The two bodies must reference the same object. The body cache ensures that the hash of the DKIM signature is valid.");
471+
472+
$email = new Email();
473+
$email->from('fabien@symfony.com');
474+
$email->to('fabien@symfony.com');
475+
$email->text('foo');
476+
$body1 = $email->getBody();
477+
$email->html('<b>bar</b>'); // We change a part to reset the body cache.
478+
$body2 = $email->getBody();
479+
$this->assertNotSame($body1, $body2, "The two bodies must not reference the same object. The body cache ensures that the hash of the DKIM signature is valid.");
480+
}
461481
}

0 commit comments

Comments
 (0)
0