mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-15 06:09:58 +08:00
refactor tests
This commit is contained in:
parent
9f2cf446b1
commit
0f7d44a2c9
@ -260,7 +260,7 @@ class AdminController extends Controller
|
||||
->setRowId('uid')
|
||||
->addColumn('operations', app('user.current')->getPermission())
|
||||
->addColumn('players_count', function ($user) {
|
||||
return Player::where('uid', $user->uid)->count();
|
||||
return $user->players->count();
|
||||
})
|
||||
->make(true);
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ class AdminControllerTest extends BrowserKitTestCase
|
||||
public function testGetPlayerData()
|
||||
{
|
||||
$player = factory(Player::class)->create();
|
||||
$user = User::find($player->uid);
|
||||
$user = $player->user;
|
||||
|
||||
$this->visit('/admin/player-data')
|
||||
->seeJsonStructure([
|
||||
|
@ -126,7 +126,7 @@ class MiddlewareTest extends TestCase
|
||||
$this->getJson("/{$player->player_name}.json");
|
||||
|
||||
$player = factory(\App\Models\Player::class)->create();
|
||||
$user = \App\Models\User::find($player->uid);
|
||||
$user = $player->user;
|
||||
$this->actAs($user)
|
||||
->postJson('/user/player/rename', [
|
||||
'pid' => -1,
|
||||
@ -148,7 +148,7 @@ class MiddlewareTest extends TestCase
|
||||
{
|
||||
$other_user = factory(\App\Models\User::class)->create();
|
||||
$player = factory(\App\Models\Player::class)->create();
|
||||
$owner = \App\Models\User::find($player->uid);
|
||||
$owner = $player->user;
|
||||
|
||||
$this->actAs($other_user)
|
||||
->get('/user/player')
|
||||
|
@ -103,7 +103,7 @@ class PlayerControllerTest extends TestCase
|
||||
public function testDelete()
|
||||
{
|
||||
$player = factory(Player::class)->create();
|
||||
$user = User::find($player->uid);
|
||||
$user = $player->user;
|
||||
$this->expectsEvents(Events\PlayerWillBeDeleted::class);
|
||||
$this->actAs($user)
|
||||
->postJson('/user/player/delete', ['pid' => $player->pid])
|
||||
@ -121,7 +121,7 @@ class PlayerControllerTest extends TestCase
|
||||
// No returning score
|
||||
option(['return_score' => false]);
|
||||
$player = factory(Player::class)->create();
|
||||
$user = User::find($player->uid);
|
||||
$user = $player->user;
|
||||
$this->actAs($user)
|
||||
->postJson('/user/player/delete', ['pid' => $player->pid])
|
||||
->assertJson([
|
||||
@ -144,7 +144,7 @@ class PlayerControllerTest extends TestCase
|
||||
public function testRename()
|
||||
{
|
||||
$player = factory(Player::class)->create();
|
||||
$user = User::find($player->uid);
|
||||
$user = $player->user;
|
||||
|
||||
// Without new player name
|
||||
$this->actAs($user)
|
||||
@ -208,7 +208,7 @@ class PlayerControllerTest extends TestCase
|
||||
public function testSetTexture()
|
||||
{
|
||||
$player = factory(Player::class)->create();
|
||||
$user = User::find($player->uid);
|
||||
$user = $player->user;
|
||||
$steve = factory(Texture::class)->create();
|
||||
$alex = factory(Texture::class, 'alex')->create();
|
||||
$cape = factory(Texture::class, 'cape')->create();
|
||||
@ -284,7 +284,7 @@ class PlayerControllerTest extends TestCase
|
||||
public function testClearTexture()
|
||||
{
|
||||
$player = factory(Player::class)->create();
|
||||
$user = User::find($player->uid);
|
||||
$user = $player->user;
|
||||
|
||||
$player->setTexture([
|
||||
'tid_steve' => 1,
|
||||
@ -314,7 +314,7 @@ class PlayerControllerTest extends TestCase
|
||||
{
|
||||
// Without `preference` field
|
||||
$player = factory(Player::class)->create();
|
||||
$this->actAs(User::find($player->uid))
|
||||
$this->actAs($player->user)
|
||||
->postJson('/user/player/preference', [
|
||||
'pid' => $player->pid
|
||||
], [
|
||||
|
@ -22,12 +22,12 @@ class TextureControllerTest extends TestCase
|
||||
|
||||
// Player is banned
|
||||
$player = factory(Player::class)->create(['tid_steve' => $steve->tid]);
|
||||
User::find($player->uid)->setPermission(User::BANNED);
|
||||
$player->user->setPermission(User::BANNED);
|
||||
$this->get("/{$player->player_name}.json")
|
||||
->assertSee(trans('general.player-banned'))
|
||||
->assertStatus(403);
|
||||
|
||||
User::find($player->uid)->setPermission(User::NORMAL);
|
||||
$player->user->setPermission(User::NORMAL);
|
||||
|
||||
// Default API is CSL API
|
||||
$this->getJson("/{$player->player_name}.json")
|
||||
|
Loading…
Reference in New Issue
Block a user