the browser-facing portion of osu!
at master 1.4 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\Transformers; 9 10use App\Models\User; 11use App\Models\UserGroupEvent; 12use Tests\TestCase; 13 14class UserGroupEventTransformerTest extends TestCase 15{ 16 public function testActorNameNotInRoot(): void 17 { 18 $eventJson = json_item(UserGroupEvent::factory()->create(), 'UserGroupEvent'); 19 20 $this->assertArrayNotHasKey('actor_name', $eventJson); 21 } 22 23 public function testActorNotVisibleWhenGuest(): void 24 { 25 $eventJson = json_item(UserGroupEvent::factory()->create(), 'UserGroupEvent'); 26 27 $this->assertArrayNotHasKey('actor', $eventJson); 28 } 29 30 public function testActorNotVisibleWhenNotInGroup(): void 31 { 32 $this->actAsUser(User::factory()->create()); 33 34 $eventJson = json_item(UserGroupEvent::factory()->create(), 'UserGroupEvent'); 35 36 $this->assertArrayNotHasKey('actor', $eventJson); 37 } 38 39 public function testActorVisibleWhenInGroup(): void 40 { 41 $event = UserGroupEvent::factory()->create(); 42 43 $this->actAsUser(User::factory()->withGroup($event->group->identifier)->create()); 44 45 $eventJson = json_item($event, 'UserGroupEvent'); 46 47 $this->assertArrayHasKey('actor', $eventJson); 48 } 49}