the browser-facing portion of osu!
at master 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 6namespace Tests\Transformers; 7 8use App\Models\Beatmapset; 9use App\Models\User; 10use Tests\TestCase; 11 12class BeatmapDiscussionTransformerTest extends TestCase 13{ 14 protected $deletedBeatmapDiscussion; 15 16 /** 17 * @dataProvider groupsDataProvider 18 */ 19 public function testWithOAuth(?string $groupIdentifier) 20 { 21 $viewer = User::factory()->withGroup($groupIdentifier)->create(); 22 23 $this->actAsScopedUser($viewer); 24 25 $json = json_item($this->deletedBeatmapDiscussion, 'BeatmapDiscussion'); 26 27 $this->assertEmpty($json); 28 } 29 30 /** 31 * @dataProvider groupsDataProvider 32 */ 33 public function testWithoutOAuth(?string $groupIdentifier, bool $visible) 34 { 35 $viewer = User::factory()->withGroup($groupIdentifier)->create(); 36 $this->actAsUser($viewer); 37 38 $json = json_item($this->deletedBeatmapDiscussion, 'BeatmapDiscussion'); 39 40 if ($visible) { 41 $this->assertNotEmpty($json); 42 } else { 43 $this->assertEmpty($json); 44 } 45 } 46 47 public static function groupsDataProvider() 48 { 49 return [ 50 ['admin', true], 51 ['bng', false], 52 ['gmt', true], 53 ['nat', true], 54 [null, false], 55 ]; 56 } 57 58 protected function setUp(): void 59 { 60 parent::setUp(); 61 62 $beatmapset = Beatmapset::factory()->owner()->withDiscussion()->create(); 63 64 $this->deletedBeatmapDiscussion = $beatmapset->beatmapDiscussions()->first(); 65 $this->deletedBeatmapDiscussion->update(['deleted_at' => now()]); 66 } 67}