mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Notifications: Add test to check notification language
This commit is contained in:
parent
4e6b74f2a1
commit
f91049a3f2
@ -2,9 +2,13 @@
|
||||
|
||||
namespace Tests\Activity;
|
||||
|
||||
use BookStack\Activity\ActivityType;
|
||||
use BookStack\Activity\Models\Comment;
|
||||
use BookStack\Activity\Notifications\Messages\BaseActivityNotification;
|
||||
use BookStack\Activity\Notifications\Messages\CommentCreationNotification;
|
||||
use BookStack\Activity\Notifications\Messages\PageCreationNotification;
|
||||
use BookStack\Activity\Notifications\Messages\PageUpdateNotification;
|
||||
use BookStack\Activity\Tools\ActivityLogger;
|
||||
use BookStack\Activity\Tools\UserEntityWatchOptions;
|
||||
use BookStack\Activity\WatchLevels;
|
||||
use BookStack\Entities\Models\Entity;
|
||||
@ -313,6 +317,43 @@ class WatchTest extends TestCase
|
||||
});
|
||||
}
|
||||
|
||||
public function test_notifications_sent_in_right_language()
|
||||
{
|
||||
$editor = $this->users->editor();
|
||||
$admin = $this->users->admin();
|
||||
setting()->putUser($editor, 'language', 'de');
|
||||
$entities = $this->entities->createChainBelongingToUser($editor);
|
||||
$watches = new UserEntityWatchOptions($editor, $entities['book']);
|
||||
$watches->updateLevelByValue(WatchLevels::COMMENTS);
|
||||
|
||||
$activities = [
|
||||
ActivityType::PAGE_CREATE => $entities['page'],
|
||||
ActivityType::PAGE_UPDATE => $entities['page'],
|
||||
ActivityType::COMMENT_CREATE => (new Comment([]))->forceFill(['entity_id' => $entities['page']->id, 'entity_type' => $entities['page']->getMorphClass()]),
|
||||
];
|
||||
|
||||
$notifications = Notification::fake();
|
||||
$logger = app()->make(ActivityLogger::class);
|
||||
$this->actingAs($admin);
|
||||
|
||||
foreach ($activities as $activityType => $detail) {
|
||||
$logger->add($activityType, $detail);
|
||||
}
|
||||
|
||||
$sent = $notifications->sentNotifications()[get_class($editor)][$editor->id];
|
||||
$this->assertCount(3, $sent);
|
||||
|
||||
foreach ($sent as $notificationInfo) {
|
||||
$notification = $notificationInfo[0]['notification'];
|
||||
$this->assertInstanceOf(BaseActivityNotification::class, $notification);
|
||||
$mail = $notification->toMail($editor);
|
||||
$mailContent = html_entity_decode(strip_tags($mail->render()));
|
||||
$this->assertStringContainsString('Name der Seite:', $mailContent);
|
||||
$this->assertStringContainsString('Diese Benachrichtigung wurde', $mailContent);
|
||||
$this->assertStringContainsString('Sollte es beim Anklicken der Schaltfläche', $mailContent);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_notifications_not_sent_if_lacking_view_permission_for_related_item()
|
||||
{
|
||||
$notifications = Notification::fake();
|
||||
|
Loading…
Reference in New Issue
Block a user