TestEmailSettingNotificationTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Tests\Feature\Notifications;
  3. use App\Models\User;
  4. use App\Notifications\TestEmailSettingNotification;
  5. use Illuminate\Notifications\Messages\MailMessage;
  6. use PHPUnit\Framework\Attributes\CoversClass;
  7. use PHPUnit\Framework\Attributes\Test;
  8. use Tests\FeatureTestCase;
  9. /**
  10. * TestEmailSettingNotificationTest test class
  11. */
  12. #[CoversClass(TestEmailSettingNotification::class)]
  13. class TestEmailSettingNotificationTest extends FeatureTestCase
  14. {
  15. /**
  16. * @var \App\Models\User
  17. */
  18. protected $user;
  19. /**
  20. * @var \App\Notifications\TestEmailSettingNotification
  21. */
  22. protected $testEmailSettingNotification;
  23. public function setUp() : void
  24. {
  25. parent::setUp();
  26. $this->user = User::factory()->create();
  27. $this->testEmailSettingNotification = new TestEmailSettingNotification('test_token');
  28. }
  29. #[Test]
  30. public function test_it_renders_to_email()
  31. {
  32. $mail = $this->testEmailSettingNotification->toMail($this->user);
  33. $this->assertInstanceOf(MailMessage::class, $mail);
  34. }
  35. #[Test]
  36. public function test_rendered_email_contains_expected_data()
  37. {
  38. $mail = $this->testEmailSettingNotification->toMail($this->user)->render();
  39. $this->assertStringContainsString(
  40. __('notifications.test_email_settings.success'),
  41. $mail
  42. );
  43. }
  44. }