Differential D21770 Diff 51891 src/applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php
Show First 20 Lines • Show All 389 Lines • ▼ Show 20 Lines | public function testMailSizeLimits() { | ||||
// We expect the body was truncated, because it exceeded the body limit. | // We expect the body was truncated, because it exceeded the body limit. | ||||
$this->assertTrue( | $this->assertTrue( | ||||
(strlen($text_body) < strlen($string_1mb)), | (strlen($text_body) < strlen($string_1mb)), | ||||
pht('Text Body Truncated')); | pht('Text Body Truncated')); | ||||
// We expect the HTML body was dropped completely after the text body was | // We expect the HTML body was dropped completely after the text body was | ||||
// truncated. | // truncated. | ||||
$this->assertTrue( | $this->assertTrue( | ||||
!strlen($html_body), | !phutil_nonempty_string($html_body), | ||||
pht('HTML Body Removed')); | pht('HTML Body Removed')); | ||||
// Next send a mail with a small text body and a large HTML body. We expect | // Next send a mail with a small text body and a large HTML body. We expect | ||||
// the text body to be intact and the HTML body to be dropped. | // the text body to be intact and the HTML body to be dropped. | ||||
$mail = id(new PhabricatorMetaMTAMail()) | $mail = id(new PhabricatorMetaMTAMail()) | ||||
->addTos(array($phid)) | ->addTos(array($phid)) | ||||
->setBody($string_1kb) | ->setBody($string_1kb) | ||||
->setHTMLBody($html_1mb); | ->setHTMLBody($html_1mb); | ||||
$mailer = new PhabricatorMailTestAdapter(); | $mailer = new PhabricatorMailTestAdapter(); | ||||
$mail->sendWithMailers(array($mailer)); | $mail->sendWithMailers(array($mailer)); | ||||
$this->assertEqual( | $this->assertEqual( | ||||
PhabricatorMailOutboundStatus::STATUS_SENT, | PhabricatorMailOutboundStatus::STATUS_SENT, | ||||
$mail->getStatus()); | $mail->getStatus()); | ||||
$text_body = $mailer->getBody(); | $text_body = $mailer->getBody(); | ||||
$html_body = $mailer->getHTMLBody(); | $html_body = $mailer->getHTMLBody(); | ||||
$this->assertEqual($string_1kb, $text_body); | $this->assertEqual($string_1kb, $text_body); | ||||
$this->assertTrue(!strlen($html_body)); | $this->assertTrue(!phutil_nonempty_string($html_body)); | ||||
} | } | ||||
} | } |