fix tests of TextureController
This commit is contained in:
parent
aa68641eba
commit
3143cf0838
|
|
@ -17,28 +17,28 @@ class TextureControllerTest extends TestCase
|
||||||
|
|
||||||
// Player is not existed
|
// Player is not existed
|
||||||
$this->get('/nope.json')
|
$this->get('/nope.json')
|
||||||
->see(trans('general.unexistent-player'))
|
->assertSee(trans('general.unexistent-player'))
|
||||||
->assertResponseStatus(404);
|
->assertStatus(404);
|
||||||
|
|
||||||
// Player is banned
|
// Player is banned
|
||||||
$player = factory(Player::class)->create(['tid_steve' => $steve->tid]);
|
$player = factory(Player::class)->create(['tid_steve' => $steve->tid]);
|
||||||
User::find($player->uid)->setPermission(User::BANNED);
|
User::find($player->uid)->setPermission(User::BANNED);
|
||||||
$this->get("/{$player->player_name}.json")
|
$this->get("/{$player->player_name}.json")
|
||||||
->see(trans('general.player-banned'))
|
->assertSee(trans('general.player-banned'))
|
||||||
->assertResponseStatus(403);
|
->assertStatus(403);
|
||||||
|
|
||||||
User::find($player->uid)->setPermission(User::NORMAL);
|
User::find($player->uid)->setPermission(User::NORMAL);
|
||||||
|
|
||||||
// Default API is CSL API
|
// Default API is CSL API
|
||||||
$this->get("/{$player->player_name}.json")
|
$this->getJson("/{$player->player_name}.json")
|
||||||
->seeJson([
|
->assertJson([
|
||||||
'username' => $player->player_name,
|
'username' => $player->player_name,
|
||||||
'skins' => [
|
'skins' => [
|
||||||
'default' => $steve->hash,
|
'default' => $steve->hash,
|
||||||
'slim' => null
|
'slim' => null
|
||||||
],
|
],
|
||||||
'cape' => null
|
'cape' => null
|
||||||
])->seeHeader('Last-Modified');
|
])->assertHeader('Last-Modified');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testJsonWithApi()
|
public function testJsonWithApi()
|
||||||
|
|
@ -47,19 +47,19 @@ class TextureControllerTest extends TestCase
|
||||||
$player = factory(Player::class)->create(['tid_steve' => $steve->tid]);
|
$player = factory(Player::class)->create(['tid_steve' => $steve->tid]);
|
||||||
|
|
||||||
// CSL API
|
// CSL API
|
||||||
$this->get("/csl/{$player->player_name}.json")
|
$this->getJson("/csl/{$player->player_name}.json")
|
||||||
->seeJson([
|
->assertJson([
|
||||||
'username' => $player->player_name,
|
'username' => $player->player_name,
|
||||||
'skins' => [
|
'skins' => [
|
||||||
'default' => $steve->hash,
|
'default' => $steve->hash,
|
||||||
'slim' => null
|
'slim' => null
|
||||||
],
|
],
|
||||||
'cape' => null
|
'cape' => null
|
||||||
])->seeHeader('Last-Modified');
|
])->assertHeader('Last-Modified');
|
||||||
|
|
||||||
// USM API
|
// USM API
|
||||||
$this->get("/usm/{$player->player_name}.json")
|
$this->getJson("/usm/{$player->player_name}.json")
|
||||||
->seeJson([
|
->assertJson([
|
||||||
'player_name' => $player->player_name,
|
'player_name' => $player->player_name,
|
||||||
'model_preference' => ['default', 'slim'],
|
'model_preference' => ['default', 'slim'],
|
||||||
'skins' => [
|
'skins' => [
|
||||||
|
|
@ -67,7 +67,7 @@ class TextureControllerTest extends TestCase
|
||||||
'slim' => null
|
'slim' => null
|
||||||
],
|
],
|
||||||
'cape' => null
|
'cape' => null
|
||||||
])->seeHeader('Last-Modified');
|
])->assertHeader('Last-Modified');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTexture()
|
public function testTexture()
|
||||||
|
|
@ -75,14 +75,14 @@ class TextureControllerTest extends TestCase
|
||||||
$steve = factory(Texture::class)->create();
|
$steve = factory(Texture::class)->create();
|
||||||
Storage::disk('textures')->put($steve->hash, '');
|
Storage::disk('textures')->put($steve->hash, '');
|
||||||
$this->get('/textures/nope')
|
$this->get('/textures/nope')
|
||||||
->see('404');
|
->assertSee('404');
|
||||||
|
|
||||||
$this->get('/textures/'.$steve->hash)
|
$this->get('/textures/'.$steve->hash)
|
||||||
->seeHeader('Content-Type', 'image/png')
|
->assertHeader('Content-Type', 'image/png')
|
||||||
->seeHeader('Last-Modified')
|
->assertHeader('Last-Modified')
|
||||||
->seeHeader('Accept-Ranges', 'bytes')
|
->assertHeader('Accept-Ranges', 'bytes')
|
||||||
->seeHeader('Content-Length', Storage::disk('textures')->size($steve->hash))
|
->assertHeader('Content-Length', Storage::disk('textures')->size($steve->hash))
|
||||||
->assertResponseStatus(200);
|
->assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTextureWithApi()
|
public function testTextureWithApi()
|
||||||
|
|
@ -91,18 +91,18 @@ class TextureControllerTest extends TestCase
|
||||||
Storage::disk('textures')->put($steve->hash, '');
|
Storage::disk('textures')->put($steve->hash, '');
|
||||||
|
|
||||||
$this->get('/csl/textures/'.$steve->hash)
|
$this->get('/csl/textures/'.$steve->hash)
|
||||||
->seeHeader('Content-Type', 'image/png')
|
->assertHeader('Content-Type', 'image/png')
|
||||||
->seeHeader('Last-Modified')
|
->assertHeader('Last-Modified')
|
||||||
->seeHeader('Accept-Ranges', 'bytes')
|
->assertHeader('Accept-Ranges', 'bytes')
|
||||||
->seeHeader('Content-Length', Storage::disk('textures')->size($steve->hash))
|
->assertHeader('Content-Length', Storage::disk('textures')->size($steve->hash))
|
||||||
->assertResponseStatus(200);
|
->assertStatus(200);
|
||||||
|
|
||||||
$this->get('/usm/textures/'.$steve->hash)
|
$this->get('/usm/textures/'.$steve->hash)
|
||||||
->seeHeader('Content-Type', 'image/png')
|
->assertHeader('Content-Type', 'image/png')
|
||||||
->seeHeader('Last-Modified')
|
->assertHeader('Last-Modified')
|
||||||
->seeHeader('Accept-Ranges', 'bytes')
|
->assertHeader('Accept-Ranges', 'bytes')
|
||||||
->seeHeader('Content-Length', Storage::disk('textures')->size($steve->hash))
|
->assertHeader('Content-Length', Storage::disk('textures')->size($steve->hash))
|
||||||
->assertResponseStatus(200);
|
->assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSkin()
|
public function testSkin()
|
||||||
|
|
@ -115,19 +115,19 @@ class TextureControllerTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->get("/skin/{$player->player_name}.png")
|
$this->get("/skin/{$player->player_name}.png")
|
||||||
->see(trans('general.texture-not-uploaded', ['type' => 'alex']));
|
->assertSee(trans('general.texture-not-uploaded', ['type' => 'alex']));
|
||||||
|
|
||||||
$player->setPreference('default');
|
$player->setPreference('default');
|
||||||
$this->get("/skin/{$player->player_name}.png")
|
$this->get("/skin/{$player->player_name}.png")
|
||||||
->see(trans('general.texture-deleted'));
|
->assertSee(trans('general.texture-deleted'));
|
||||||
|
|
||||||
Storage::disk('textures')->put($steve->hash, '');
|
Storage::disk('textures')->put($steve->hash, '');
|
||||||
$this->get("/skin/{$player->player_name}.png")
|
$this->get("/skin/{$player->player_name}.png")
|
||||||
->seeHeader('Content-Type', 'image/png')
|
->assertHeader('Content-Type', 'image/png')
|
||||||
->seeHeader('Last-Modified')
|
->assertHeader('Last-Modified')
|
||||||
->seeHeader('Accept-Ranges', 'bytes')
|
->assertHeader('Accept-Ranges', 'bytes')
|
||||||
->seeHeader('Content-Length', Storage::disk('textures')->size($steve->hash))
|
->assertHeader('Content-Length', Storage::disk('textures')->size($steve->hash))
|
||||||
->assertResponseStatus(200);
|
->assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSkinWithModel()
|
public function testSkinWithModel()
|
||||||
|
|
@ -140,11 +140,11 @@ class TextureControllerTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->get("/skin/alex/{$player->player_name}.png")
|
$this->get("/skin/alex/{$player->player_name}.png")
|
||||||
->see(trans('general.texture-not-uploaded', ['type' => 'alex']));
|
->assertSee(trans('general.texture-not-uploaded', ['type' => 'alex']));
|
||||||
|
|
||||||
$player->setPreference('default');
|
$player->setPreference('default');
|
||||||
$this->get("/skin/steve/{$player->player_name}.png")
|
$this->get("/skin/steve/{$player->player_name}.png")
|
||||||
->see(trans('general.texture-deleted'));
|
->assertSee(trans('general.texture-deleted'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCape()
|
public function testCape()
|
||||||
|
|
@ -155,14 +155,14 @@ class TextureControllerTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->get("/cape/{$player->player_name}.png")
|
$this->get("/cape/{$player->player_name}.png")
|
||||||
->see(trans('general.texture-deleted'));
|
->assertSee(trans('general.texture-deleted'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAvatar()
|
public function testAvatar()
|
||||||
{
|
{
|
||||||
$base64_email = base64_encode('a@b.c');
|
$base64_email = base64_encode('a@b.c');
|
||||||
$this->get("/avatar/$base64_email.png")
|
$this->get("/avatar/$base64_email.png")
|
||||||
->seeHeader('Content-Type', 'image/png');
|
->assertHeader('Content-Type', 'image/png');
|
||||||
|
|
||||||
$steve = factory(Texture::class)->create();
|
$steve = factory(Texture::class)->create();
|
||||||
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSteveSkin());
|
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSteveSkin());
|
||||||
|
|
@ -177,7 +177,7 @@ class TextureControllerTest extends TestCase
|
||||||
|
|
||||||
$this->expectsEvents(\App\Events\GetAvatarPreview::class);
|
$this->expectsEvents(\App\Events\GetAvatarPreview::class);
|
||||||
$this->get('/avatar/'.base64_encode($user->email).'.png')
|
$this->get('/avatar/'.base64_encode($user->email).'.png')
|
||||||
->seeHeader('Content-Type', 'image/png');
|
->assertHeader('Content-Type', 'image/png');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAvatarWithSize()
|
public function testAvatarWithSize()
|
||||||
|
|
@ -195,7 +195,7 @@ class TextureControllerTest extends TestCase
|
||||||
|
|
||||||
$this->expectsEvents(\App\Events\GetAvatarPreview::class);
|
$this->expectsEvents(\App\Events\GetAvatarPreview::class);
|
||||||
$this->get('/avatar/50/'.base64_encode($user->email).'.png')
|
$this->get('/avatar/50/'.base64_encode($user->email).'.png')
|
||||||
->seeHeader('Content-Type', 'image/png');
|
->assertHeader('Content-Type', 'image/png');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPreview()
|
public function testPreview()
|
||||||
|
|
@ -204,10 +204,10 @@ class TextureControllerTest extends TestCase
|
||||||
$cape = factory(Texture::class, 'cape')->create();
|
$cape = factory(Texture::class, 'cape')->create();
|
||||||
|
|
||||||
$this->get('/preview/0.png')
|
$this->get('/preview/0.png')
|
||||||
->seeHeader('Content-Type', 'image/png');
|
->assertHeader('Content-Type', 'image/png');
|
||||||
|
|
||||||
$this->get("/preview/{$steve->tid}.png")
|
$this->get("/preview/{$steve->tid}.png")
|
||||||
->seeHeader('Content-Type', 'image/png');
|
->assertHeader('Content-Type', 'image/png');
|
||||||
|
|
||||||
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSteveSkin());
|
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSteveSkin());
|
||||||
Storage::disk('textures')->put($steve->hash, $png);
|
Storage::disk('textures')->put($steve->hash, $png);
|
||||||
|
|
@ -219,19 +219,19 @@ class TextureControllerTest extends TestCase
|
||||||
->andReturn(imagecreatefromstring($png));
|
->andReturn(imagecreatefromstring($png));
|
||||||
$this->expectsEvents(\App\Events\GetSkinPreview::class);
|
$this->expectsEvents(\App\Events\GetSkinPreview::class);
|
||||||
$this->get("/preview/{$steve->tid}.png")
|
$this->get("/preview/{$steve->tid}.png")
|
||||||
->seeHeader('Content-Type', 'image/png');
|
->assertHeader('Content-Type', 'image/png');
|
||||||
|
|
||||||
$mock->shouldReceive('generatePreviewFromCape')
|
$mock->shouldReceive('generatePreviewFromCape')
|
||||||
->once()
|
->once()
|
||||||
->andReturn(imagecreatefromstring($png));
|
->andReturn(imagecreatefromstring($png));
|
||||||
$this->get("/preview/{$cape->tid}.png")
|
$this->get("/preview/{$cape->tid}.png")
|
||||||
->seeHeader('Content-Type', 'image/png');
|
->assertHeader('Content-Type', 'image/png');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPreviewWithSize()
|
public function testPreviewWithSize()
|
||||||
{
|
{
|
||||||
$this->get('/preview/200/0.png')
|
$this->get('/preview/200/0.png')
|
||||||
->seeHeader('Content-Type', 'image/png');
|
->assertHeader('Content-Type', 'image/png');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRaw()
|
public function testRaw()
|
||||||
|
|
@ -241,15 +241,15 @@ class TextureControllerTest extends TestCase
|
||||||
|
|
||||||
// Not found
|
// Not found
|
||||||
$this->get('/raw/0.png')
|
$this->get('/raw/0.png')
|
||||||
->see(trans('skinlib.non-existent'));
|
->assertSee(trans('skinlib.non-existent'));
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
$this->get("/raw/{$steve->tid}.png")
|
$this->get("/raw/{$steve->tid}.png")
|
||||||
->seeHeader('Content-Type', 'image/png');
|
->assertHeader('Content-Type', 'image/png');
|
||||||
|
|
||||||
// Texture is deleted
|
// Texture is deleted
|
||||||
Storage::disk('textures')->delete($steve->hash);
|
Storage::disk('textures')->delete($steve->hash);
|
||||||
$this->get("/raw/{$steve->tid}.png")
|
$this->get("/raw/{$steve->tid}.png")
|
||||||
->see(trans('general.texture-deleted'));
|
->assertSee(trans('general.texture-deleted'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user