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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy