the browser-facing portion of osu!
at master 56 lines 1.5 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 BeatmapsetTransformerTest extends TestCase 13{ 14 /** 15 * @dataProvider groupsDataProvider 16 */ 17 public function testDeletedBeatmapsetGroupPermissionsWithOAuth(?string $groupIdentifier) 18 { 19 $viewer = User::factory()->withGroup($groupIdentifier)->create(); 20 $beatmapset = Beatmapset::factory()->deleted()->create(); 21 $this->actAsScopedUser($viewer); 22 23 $json = json_item($beatmapset, 'Beatmapset'); 24 25 $this->assertEmpty($json); 26 } 27 28 /** 29 * @dataProvider groupsDataProvider 30 */ 31 public function testDeletedBeatmapsetGroupPermissionsWithoutOAuth(?string $groupIdentifier, bool $visible) 32 { 33 $viewer = User::factory()->withGroup($groupIdentifier)->create(); 34 $beatmapset = Beatmapset::factory()->deleted()->create(); 35 $this->actAsUser($viewer); 36 37 $json = json_item($beatmapset, 'Beatmapset'); 38 39 if ($visible) { 40 $this->assertNotEmpty($json); 41 } else { 42 $this->assertEmpty($json); 43 } 44 } 45 46 public static function groupsDataProvider() 47 { 48 return [ 49 ['admin', true], 50 ['bng', true], 51 ['gmt', true], 52 ['nat', true], 53 [null, false], 54 ]; 55 } 56}