1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Notifications: Reorgranised classes into domain specific folders

Closes #4500
This commit is contained in:
Dan Brown
2023-09-11 19:26:28 +01:00
parent 18f396c21b
commit 8e3f8de627
15 changed files with 36 additions and 33 deletions

View File

@@ -2,11 +2,11 @@
namespace Tests\Api;
use BookStack\Access\Notifications\UserInviteNotification;
use BookStack\Activity\ActivityType;
use BookStack\Activity\Models\Activity as ActivityModel;
use BookStack\Entities\Models\Entity;
use BookStack\Facades\Activity;
use BookStack\Notifications\UserInvite;
use BookStack\Users\Models\Role;
use BookStack\Users\Models\User;
use Illuminate\Support\Facades\Hash;
@@ -140,7 +140,7 @@ class UsersApiTest extends TestCase
$resp->assertStatus(200);
/** @var User $user */
$user = User::query()->where('email', '=', 'bboris@example.com')->first();
Notification::assertSentTo($user, UserInvite::class);
Notification::assertSentTo($user, UserInviteNotification::class);
}
public function test_create_name_and_email_validation()

View File

@@ -2,7 +2,7 @@
namespace Tests\Auth;
use BookStack\Notifications\ConfirmEmail;
use BookStack\Access\Notifications\ConfirmEmailNotification;
use BookStack\Users\Models\Role;
use BookStack\Users\Models\User;
use Illuminate\Support\Facades\DB;
@@ -28,7 +28,7 @@ class RegistrationTest extends TestCase
// Ensure notification sent
/** @var User $dbUser */
$dbUser = User::query()->where('email', '=', $user->email)->first();
Notification::assertSentTo($dbUser, ConfirmEmail::class);
Notification::assertSentTo($dbUser, ConfirmEmailNotification::class);
// Test access and resend confirmation email
$resp = $this->post('/login', ['email' => $user->email, 'password' => $user->password]);
@@ -42,7 +42,7 @@ class RegistrationTest extends TestCase
// Get confirmation and confirm notification matches
$emailConfirmation = DB::table('email_confirmations')->where('user_id', '=', $dbUser->id)->first();
Notification::assertSentTo($dbUser, ConfirmEmail::class, function ($notification, $channels) use ($emailConfirmation) {
Notification::assertSentTo($dbUser, ConfirmEmailNotification::class, function ($notification, $channels) use ($emailConfirmation) {
return $notification->token === $emailConfirmation->token;
});

View File

@@ -2,7 +2,7 @@
namespace Tests\Auth;
use BookStack\Notifications\ResetPassword;
use BookStack\Access\Notifications\ResetPasswordNotification;
use BookStack\Users\Models\User;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
@@ -34,8 +34,8 @@ class ResetPasswordTest extends TestCase
/** @var User $user */
$user = User::query()->where('email', '=', 'admin@admin.com')->first();
Notification::assertSentTo($user, ResetPassword::class);
$n = Notification::sent($user, ResetPassword::class);
Notification::assertSentTo($user, ResetPasswordNotification::class);
$n = Notification::sent($user, ResetPasswordNotification::class);
$this->get('/password/reset/' . $n->first()->token)
->assertOk()
@@ -95,7 +95,7 @@ class ResetPasswordTest extends TestCase
$resp = $this->followingRedirects()->post('/password/email', [
'email' => $editor->email,
]);
Notification::assertTimesSent(1, ResetPassword::class);
Notification::assertTimesSent(1, ResetPasswordNotification::class);
$resp->assertSee('A password reset link will be sent to ' . $editor->email . ' if that email address is found in the system.');
}
}

View File

@@ -2,8 +2,8 @@
namespace Tests\Auth;
use BookStack\Access\Notifications\UserInviteNotification;
use BookStack\Access\UserInviteService;
use BookStack\Notifications\UserInvite;
use BookStack\Users\Models\User;
use Carbon\Carbon;
use Illuminate\Notifications\Messages\MailMessage;
@@ -29,7 +29,7 @@ class UserInviteTest extends TestCase
$newUser = User::query()->where('email', '=', $email)->orderBy('id', 'desc')->first();
Notification::assertSentTo($newUser, UserInvite::class);
Notification::assertSentTo($newUser, UserInviteNotification::class);
$this->assertDatabaseHas('user_invites', [
'user_id' => $newUser->id,
]);
@@ -50,7 +50,7 @@ class UserInviteTest extends TestCase
$resp->assertRedirect('/settings/users');
$newUser = User::query()->where('email', '=', $email)->orderBy('id', 'desc')->first();
Notification::assertSentTo($newUser, UserInvite::class, function ($notification, $channels, $notifiable) {
Notification::assertSentTo($newUser, UserInviteNotification::class, function ($notification, $channels, $notifiable) {
/** @var MailMessage $mail */
$mail = $notification->toMail($notifiable);

View File

@@ -2,7 +2,7 @@
namespace Tests\Settings;
use BookStack\Notifications\TestEmail;
use BookStack\Settings\TestEmailNotification;
use Illuminate\Contracts\Notifications\Dispatcher;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
@@ -26,7 +26,7 @@ class TestEmailTest extends TestCase
$sendReq->assertRedirect('/settings/maintenance#image-cleanup');
$this->assertSessionHas('success', 'Email sent to ' . $admin->email);
Notification::assertSentTo($admin, TestEmail::class);
Notification::assertSentTo($admin, TestEmailNotification::class);
}
public function test_send_test_email_failure_displays_error_notification()
@@ -57,6 +57,6 @@ class TestEmailTest extends TestCase
$this->permissions->grantUserRolePermissions($user, ['settings-manage']);
$sendReq = $this->actingAs($user)->post('/settings/maintenance/send-test-email');
Notification::assertSentTo($user, TestEmail::class);
Notification::assertSentTo($user, TestEmailNotification::class);
}
}