8889841cPKà»[D`ÿÜÜ#Constraint/EmailAttachmentCount.phpnu„[µü¤ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mime\Test\Constraint; use PHPUnit\Framework\Constraint\Constraint; use Symfony\Component\Mime\Message; use Symfony\Component\Mime\RawMessage; final class EmailAttachmentCount extends Constraint { private $expectedValue; private $transport; public function __construct(int $expectedValue, string $transport = null) { $this->expectedValue = $expectedValue; $this->transport = $transport; } /** * {@inheritdoc} */ public function toString(): string { return sprintf('has sent "%d" attachment(s)', $this->expectedValue); } /** * @param RawMessage $message * * {@inheritdoc} */ protected function matches($message): bool { if (RawMessage::class === \get_class($message) || Message::class === \get_class($message)) { throw new \LogicException('Unable to test a message attachment on a RawMessage or Message instance.'); } return $this->expectedValue === \count($message->getAttachments()); } /** * @param RawMessage $message * * {@inheritdoc} */ protected function failureDescription($message): string { return 'the Email '.$this->toString(); } } PKà»[J µZZ#Constraint/EmailAddressContains.phpnu„[µü¤ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mime\Test\Constraint; use PHPUnit\Framework\Constraint\Constraint; use Symfony\Component\Mime\Header\MailboxHeader; use Symfony\Component\Mime\Header\MailboxListHeader; use Symfony\Component\Mime\RawMessage; final class EmailAddressContains extends Constraint { private $headerName; private $expectedValue; public function __construct(string $headerName, string $expectedValue) { $this->headerName = $headerName; $this->expectedValue = $expectedValue; } /** * {@inheritdoc} */ public function toString(): string { return sprintf('contains address "%s" with value "%s"', $this->headerName, $this->expectedValue); } /** * @param RawMessage $message * * {@inheritdoc} */ protected function matches($message): bool { if (RawMessage::class === \get_class($message)) { throw new \LogicException('Unable to test a message address on a RawMessage instance.'); } $header = $message->getHeaders()->get($this->headerName); if ($header instanceof MailboxHeader) { return $this->expectedValue === $header->getAddress()->getAddress(); } elseif ($header instanceof MailboxListHeader) { foreach ($header->getAddresses() as $address) { if ($this->expectedValue === $address->getAddress()) { return true; } } return false; } throw new \LogicException('Unable to test a message address on a non-address header.'); } /** * @param RawMessage $message * * {@inheritdoc} */ protected function failureDescription($message): string { return sprintf('the Email %s (value is %s)', $this->toString(), $message->getHeaders()->get($this->headerName)->getBodyAsString()); } } PKà»[ÎÑ”nƒƒ$Constraint/EmailTextBodyContains.phpnu„[µü¤ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mime\Test\Constraint; use PHPUnit\Framework\Constraint\Constraint; use Symfony\Component\Mime\Message; use Symfony\Component\Mime\RawMessage; final class EmailTextBodyContains extends Constraint { private $expectedText; public function __construct(string $expectedText) { $this->expectedText = $expectedText; } /** * {@inheritdoc} */ public function toString(): string { return sprintf('contains "%s"', $this->expectedText); } /** * {@inheritdoc} * * @param RawMessage $message */ protected function matches($message): bool { if (RawMessage::class === \get_class($message) || Message::class === \get_class($message)) { throw new \LogicException('Unable to test a message text body on a RawMessage or Message instance.'); } return false !== mb_strpos($message->getTextBody(), $this->expectedText); } /** * {@inheritdoc} * * @param RawMessage $message */ protected function failureDescription($message): string { return 'the Email text body '.$this->toString(); } } PKà»[}ãÄTúúConstraint/EmailHasHeader.phpnu„[µü¤ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mime\Test\Constraint; use PHPUnit\Framework\Constraint\Constraint; use Symfony\Component\Mime\RawMessage; final class EmailHasHeader extends Constraint { private $headerName; public function __construct(string $headerName) { $this->headerName = $headerName; } /** * {@inheritdoc} */ public function toString(): string { return sprintf('has header "%s"', $this->headerName); } /** * @param RawMessage $message * * {@inheritdoc} */ protected function matches($message): bool { if (RawMessage::class === \get_class($message)) { throw new \LogicException('Unable to test a message header on a RawMessage instance.'); } return $message->getHeaders()->has($this->headerName); } /** * @param RawMessage $message * * {@inheritdoc} */ protected function failureDescription($message): string { return 'the Email '.$this->toString(); } } PKà»[±§5#ííConstraint/EmailHeaderSame.phpnu„[µü¤ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mime\Test\Constraint; use PHPUnit\Framework\Constraint\Constraint; use Symfony\Component\Mime\Header\UnstructuredHeader; use Symfony\Component\Mime\RawMessage; final class EmailHeaderSame extends Constraint { private $headerName; private $expectedValue; public function __construct(string $headerName, string $expectedValue) { $this->headerName = $headerName; $this->expectedValue = $expectedValue; } /** * {@inheritdoc} */ public function toString(): string { return sprintf('has header "%s" with value "%s"', $this->headerName, $this->expectedValue); } /** * @param RawMessage $message * * {@inheritdoc} */ protected function matches($message): bool { if (RawMessage::class === \get_class($message)) { throw new \LogicException('Unable to test a message header on a RawMessage instance.'); } return $this->expectedValue === $this->getHeaderValue($message); } /** * @param RawMessage $message * * {@inheritdoc} */ protected function failureDescription($message): string { return sprintf('the Email %s (value is %s)', $this->toString(), $this->getHeaderValue($message)); } private function getHeaderValue($message): string { $header = $message->getHeaders()->get($this->headerName); return $header instanceof UnstructuredHeader ? $header->getValue() : $header->getBodyAsString(); } } PKà»[q”Óƒƒ$Constraint/EmailHtmlBodyContains.phpnu„[µü¤ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mime\Test\Constraint; use PHPUnit\Framework\Constraint\Constraint; use Symfony\Component\Mime\Message; use Symfony\Component\Mime\RawMessage; final class EmailHtmlBodyContains extends Constraint { private $expectedText; public function __construct(string $expectedText) { $this->expectedText = $expectedText; } /** * {@inheritdoc} */ public function toString(): string { return sprintf('contains "%s"', $this->expectedText); } /** * {@inheritdoc} * * @param RawMessage $message */ protected function matches($message): bool { if (RawMessage::class === \get_class($message) || Message::class === \get_class($message)) { throw new \LogicException('Unable to test a message HTML body on a RawMessage or Message instance.'); } return false !== mb_strpos($message->getHtmlBody(), $this->expectedText); } /** * {@inheritdoc} * * @param RawMessage $message */ protected function failureDescription($message): string { return 'the Email HTML body '.$this->toString(); } } PKà»[D`ÿÜÜ#Constraint/EmailAttachmentCount.phpnu„[µü¤PKà»[J µZZ#/Constraint/EmailAddressContains.phpnu„[µü¤PKà»[ÎÑ”nƒƒ$ÜConstraint/EmailTextBodyContains.phpnu„[µü¤PKà»[}ãÄTúú³Constraint/EmailHasHeader.phpnu„[µü¤PKà»[±§5#ííúConstraint/EmailHeaderSame.phpnu„[µü¤PKà»[q”Óƒƒ$5!Constraint/EmailHtmlBodyContains.phpnu„[µü¤PKI '