Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Mail;
  4.  
  5. use Illuminate\Container\Container;
  6. use Illuminate\Mail\Mailable as BaseMailable;
  7. use PHPUnit\Framework\Assert;
  8.  
  9. class Mailable extends BaseMailable
  10. {
  11. /**
  12. * @return array
  13. */
  14. public function getRenderedBody() : array
  15. {
  16. Container::getInstance()->call([$this, 'build']);
  17.  
  18. return $this->buildView();
  19. }
  20.  
  21. /**
  22. * @param string $string
  23. *
  24. * @return $this
  25. */
  26. public function assertHtmlBodyContains(string $string)
  27. {
  28. Assert::assertTrue(
  29. str_contains($this->getRenderedBody()['html'], $string),
  30. "The rendered HTML body does not contain \"$string\"."
  31. );
  32.  
  33. return $this;
  34. }
  35.  
  36. /**
  37. * @param string $string
  38. *
  39. * @return $this
  40. */
  41. public function assertTextBodyContains(string $string)
  42. {
  43. Assert::assertTrue(
  44. str_contains($this->getRenderedBody()['text'], $string),
  45. "The rendered text body does not contain \"$string\"."
  46. );
  47.  
  48. return $this;
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement