the browser-facing portion of osu!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Tweak test to use `actAsScopedUser()`

+5 -11
+5 -11
tests/Controllers/Multiplayer/RoomsControllerTest.php
··· 431 431 432 432 public function testDestroy() 433 433 { 434 - $token = Token::factory()->create(['scopes' => ['*']]); 435 434 $start = now(); 436 435 $end = $start->clone()->addMinutes(60); 437 436 $room = Room::factory()->create([ 438 - 'user_id' => $token->user, 439 437 'starts_at' => $start, 440 438 'ends_at' => $end, 441 439 'type' => Room::PLAYLIST_TYPE, ··· 443 441 $end = $room->ends_at; // assignment truncates fractional second part, so refetch here 444 442 $url = route('api.rooms.destroy', ['room' => $room]); 445 443 444 + $this->actAsScopedUser($room->host); 446 445 $this 447 - ->actingWithToken($token) 448 446 ->delete($url) 449 447 ->assertSuccessful(); 450 448 ··· 454 452 455 453 public function testDestroyCannotBeCalledOnRealtimeRoom() 456 454 { 457 - $token = Token::factory()->create(['scopes' => ['*']]); 458 455 $start = now(); 459 456 $end = $start->clone()->addMinutes(60); 460 457 $room = Room::factory()->create([ 461 - 'user_id' => $token->user, 462 458 'starts_at' => $start, 463 459 'ends_at' => $end, 464 460 'type' => Room::REALTIME_DEFAULT_TYPE, ··· 466 462 $end = $room->ends_at; // assignment truncates fractional second part, so refetch here 467 463 $url = route('api.rooms.destroy', ['room' => $room]); 468 464 465 + $this->actAsScopedUser($room->host); 469 466 $this 470 - ->actingWithToken($token) 471 467 ->delete($url) 472 468 ->assertStatus(422); 473 469 ··· 477 473 478 474 public function testDestroyCannotBeCalledByAnotherUser() 479 475 { 476 + $requester = User::factory()->create(); 480 477 $owner = User::factory()->create(); 481 - $token = Token::factory()->create(['scopes' => ['*']]); 482 478 $start = now(); 483 479 $end = $start->clone()->addMinutes(60); 484 480 $room = Room::factory()->create([ ··· 490 486 $url = route('api.rooms.destroy', ['room' => $room]); 491 487 $end = $room->ends_at; // assignment truncates fractional second part, so refetch here 492 488 489 + $this->actAsScopedUser($requester); 493 490 $this 494 - ->actingWithToken($token) 495 491 ->delete($url) 496 492 ->assertStatus(403); 497 493 ··· 501 497 502 498 public function testDestroyCannotBeCalledAfterGracePeriod() 503 499 { 504 - $token = Token::factory()->create(['scopes' => ['*']]); 505 500 $start = now(); 506 501 $end = $start->clone()->addMinutes(60); 507 502 $room = Room::factory()->create([ 508 - 'user_id' => $token->user, 509 503 'starts_at' => $start, 510 504 'ends_at' => $end, 511 505 'type' => Room::PLAYLIST_TYPE, ··· 513 507 $url = route('api.rooms.destroy', ['room' => $room]); 514 508 $end = $room->ends_at; // assignment truncates fractional second part, so refetch here 515 509 510 + $this->actAsScopedUser($room->host); 516 511 $this->travelTo($start->addMinutes(6)); 517 512 $this 518 - ->actingWithToken($token) 519 513 ->delete($url) 520 514 ->assertStatus(422); 521 515