Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Mail;
- use Illuminate\Container\Container;
- use Illuminate\Mail\Mailable as BaseMailable;
- use PHPUnit\Framework\Assert;
- class Mailable extends BaseMailable
- {
- /**
- * @return array
- */
- public function getRenderedBody() : array
- {
- Container::getInstance()->call([$this, 'build']);
- return $this->buildView();
- }
- /**
- * @param string $string
- *
- * @return $this
- */
- public function assertHtmlBodyContains(string $string)
- {
- Assert::assertTrue(
- str_contains($this->getRenderedBody()['html'], $string),
- "The rendered HTML body does not contain \"$string\"."
- );
- return $this;
- }
- /**
- * @param string $string
- *
- * @return $this
- */
- public function assertTextBodyContains(string $string)
- {
- Assert::assertTrue(
- str_contains($this->getRenderedBody()['text'], $string),
- "The rendered text body does not contain \"$string\"."
- );
- return $this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement