the browser-facing portion of osu!
at master 54 lines 1.8 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6declare(strict_types=1); 7 8namespace Tests\Jobs; 9 10use App\Models\Forum\Forum; 11use App\Models\Forum\Topic; 12use App\Models\Forum\TopicWatch; 13use App\Models\Notification; 14use App\Models\User; 15use App\Models\UserNotification; 16use Tests\TestCase; 17 18class UpdateUserForumTopicFollowsTest extends TestCase 19{ 20 public function testRemoveUserWithNoWatchPermission(): void 21 { 22 $adminForum = Forum::factory()->create(); 23 config_set('osu.forum.admin_forum_id', $adminForum->getKey()); 24 $normalForum = Forum::factory()->create(); 25 $topic = Topic::factory()->create(); 26 $user = User::factory()->create(); 27 28 TopicWatch::setState($topic, $user, 'watching_mail'); 29 $notification = Notification::create([ 30 'notifiable_id' => $topic->getKey(), 31 'notifiable_type' => $topic->getMorphClass(), 32 'name' => Notification::FORUM_TOPIC_REPLY, 33 'details' => [], 34 ]); 35 UserNotification::create([ 36 'notification_id' => $notification->getKey(), 37 'user_id' => $user->getKey(), 38 'created_at' => now()->subHours(1), 39 ]); 40 41 $watchesCount = TopicWatch::count(); 42 $userNotificationsCount = UserNotification::count(); 43 44 $topic->moveTo($normalForum); 45 46 $this->assertSame($watchesCount, TopicWatch::count()); 47 $this->assertSame($userNotificationsCount, UserNotification::count()); 48 49 $topic->moveTo($adminForum); 50 51 $this->assertSame($watchesCount - 1, TopicWatch::count()); 52 $this->assertSame($userNotificationsCount - 1, UserNotification::count()); 53 } 54}