diff --git a/app/Mail/InvitedToSpace.php b/app/Mail/InvitedToSpace.php
index 51e1b76b..7385a58a 100644
--- a/app/Mail/InvitedToSpace.php
+++ b/app/Mail/InvitedToSpace.php
@@ -12,11 +12,10 @@ class InvitedToSpace extends Mailable
use Queueable;
use SerializesModels;
- protected $invite;
-
- public function __construct(SpaceInvite $invite)
- {
- $this->invite = $invite;
+ public function __construct(
+ protected SpaceInvite $invite,
+ ) {
+ //
}
public function build()
diff --git a/app/Mail/PasswordChanged.php b/app/Mail/PasswordChanged.php
index 6b9d7f18..a0202ade 100644
--- a/app/Mail/PasswordChanged.php
+++ b/app/Mail/PasswordChanged.php
@@ -11,11 +11,10 @@ class PasswordChanged extends Mailable
use Queueable;
use SerializesModels;
- protected $updated_at;
-
- public function __construct($updated_at)
- {
- $this->updated_at = $updated_at;
+ public function __construct(
+ protected $updated_at,
+ ) {
+ //
}
public function build()
diff --git a/app/Mail/ResetPassword.php b/app/Mail/ResetPassword.php
index 63c2f704..b0e614b1 100644
--- a/app/Mail/ResetPassword.php
+++ b/app/Mail/ResetPassword.php
@@ -11,11 +11,10 @@ class ResetPassword extends Mailable
use Queueable;
use SerializesModels;
- protected $token;
-
- public function __construct($token)
- {
- $this->token = $token;
+ public function __construct(
+ protected $token,
+ ) {
+ //
}
public function build()
diff --git a/app/Mail/VerifyRegistration.php b/app/Mail/VerifyRegistration.php
index 0e65557d..b20c7f17 100644
--- a/app/Mail/VerifyRegistration.php
+++ b/app/Mail/VerifyRegistration.php
@@ -12,11 +12,10 @@ class VerifyRegistration extends Mailable
use Queueable;
use SerializesModels;
- protected $user;
-
- public function __construct(User $user)
- {
- $this->user = $user;
+ public function __construct(
+ protected User $user,
+ ) {
+ //
}
public function build()
diff --git a/app/Mail/WeeklyReport.php b/app/Mail/WeeklyReport.php
index 2f9fe593..c81f5375 100644
--- a/app/Mail/WeeklyReport.php
+++ b/app/Mail/WeeklyReport.php
@@ -12,17 +12,13 @@ class WeeklyReport extends Mailable
use Queueable;
use SerializesModels;
- protected $space;
- protected $week;
- protected $totalSpent;
- protected $largestSpendingWithTag;
-
- public function __construct(Space $space, $week, $totalSpent, $largestSpendingWithTag)
- {
- $this->space = $space;
- $this->week = $week;
- $this->totalSpent = $totalSpent;
- $this->largestSpendingWithTag = $largestSpendingWithTag;
+ public function __construct(
+ protected Space $space,
+ protected $week,
+ protected $totalSpent,
+ protected $largestSpendingWithTag
+ ) {
+ //
}
public function build()
diff --git a/resources/views/emails/invited_to_space_plain.blade.php b/resources/views/emails/invited_to_space_plain.blade.php
index eb0a0490..16cd1cc7 100644
--- a/resources/views/emails/invited_to_space_plain.blade.php
+++ b/resources/views/emails/invited_to_space_plain.blade.php
@@ -1,4 +1,4 @@
-{{ $invite->inviter->name }} has invited you to "{{ $invite->space->name }}"
+{{ $invite->inviter->name }} has invited you to "{{ $invite->space->name }}".
Use the link below to check out your invite.
diff --git a/tests/Unit/Mail/InvitedToSpaceTest.php b/tests/Unit/Mail/InvitedToSpaceTest.php
new file mode 100644
index 00000000..761d3db2
--- /dev/null
+++ b/tests/Unit/Mail/InvitedToSpaceTest.php
@@ -0,0 +1,37 @@
+create([
+ 'name' => 'Foo Bar',
+ ]);
+
+ $inviterUser = User::factory()
+ ->create([
+ 'name' => 'John Doe',
+ ]);
+
+ $spaceInvite = SpaceInvite::factory()
+ ->create([
+ 'space_id' => $space->id,
+ 'inviter_user_id' => $inviterUser->id,
+ ]);
+
+ $mailable = new InvitedToSpace($spaceInvite);
+
+ $mailable
+ ->assertSeeInText('John Doe has invited you to "Foo Bar".')
+ ->assertSeeInHtml('Check out your invite', false); // phpcs:ignore
+ }
+}
diff --git a/tests/Unit/Mail/PasswordChangedTest.php b/tests/Unit/Mail/PasswordChangedTest.php
new file mode 100644
index 00000000..c557f9b1
--- /dev/null
+++ b/tests/Unit/Mail/PasswordChangedTest.php
@@ -0,0 +1,16 @@
+assertSeeInText('Heads up! Your password has been changed (2023-12-05 18:00:00 CEST).');
+ }
+}
diff --git a/tests/Unit/Mail/ResetPasswordTest.php b/tests/Unit/Mail/ResetPasswordTest.php
new file mode 100644
index 00000000..00785135
--- /dev/null
+++ b/tests/Unit/Mail/ResetPasswordTest.php
@@ -0,0 +1,16 @@
+assertSeeInHtml('Click here to change your password', false); // phpcs:ignore
+ }
+}
diff --git a/tests/Unit/Mail/VerifyRegistrationTest.php b/tests/Unit/Mail/VerifyRegistrationTest.php
new file mode 100644
index 00000000..54454ef1
--- /dev/null
+++ b/tests/Unit/Mail/VerifyRegistrationTest.php
@@ -0,0 +1,27 @@
+create([
+ 'name' => 'John Doe',
+ 'verification_token' => 'abc123',
+ ]);
+
+ $mailable = new VerifyRegistration($user);
+
+ $mailable
+ ->assertSeeInText('Welcome aboard, John Doe')
+ ->assertSeeInText('We\'re going to help you get insight into your personal finances.')
+ ->assertSeeInText('No more dealing with pesky, half-assed spreadsheets.')
+ ->assertSeeInHtml('Verify', false);
+ }
+}
diff --git a/tests/Unit/Mail/WeeklyReportTest.php b/tests/Unit/Mail/WeeklyReportTest.php
new file mode 100644
index 00000000..4b56410f
--- /dev/null
+++ b/tests/Unit/Mail/WeeklyReportTest.php
@@ -0,0 +1,54 @@
+create([
+ 'currency_id' => 2, // Should be USD
+ 'name' => 'Foo Bar',
+ ]);
+
+ $mailable = new WeeklyReport(
+ space: $space,
+ week: 5,
+ totalSpent: 0,
+ largestSpendingWithTag: [],
+ );
+
+ $mailable
+ ->assertSeeInText('Here\'s your weekly report for Foo Bar')
+ ->assertSeeInText('This week (#5) you\'ve')
+ ->assertSeeInText('- Spent $ 0.00')
+ ->assertDontSeeInText('Most of which you\'ve spent on');
+ }
+
+ public function testMailableUsingSpaceWithTransactions(): void
+ {
+ $space = Space::factory()
+ ->create([
+ 'currency_id' => 2, // Should be USD
+ 'name' => 'Foo Bar',
+ ]);
+
+ $mailable = new WeeklyReport(
+ space: $space,
+ week: 5,
+ totalSpent: 10000,
+ largestSpendingWithTag: [(object) ['amount' => 7000, 'tag_name' => 'Insurance']],
+ );
+
+ $mailable
+ ->assertSeeInText('Here\'s your weekly report for Foo Bar')
+ ->assertSeeInText('This week (#5) you\'ve')
+ ->assertSeeInText('- Spent $ 100.00')
+ ->assertSeeInText('- Most of which you\'ve spent on Insurance ($ 70.00)');
+ }
+}