mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-21 06:19:38 +08:00
33 lines
908 B
PHP
33 lines
908 B
PHP
|
<?php
|
||
|
|
||
|
namespace Tests;
|
||
|
|
||
|
use Cache;
|
||
|
use Event;
|
||
|
use Mockery;
|
||
|
use Storage;
|
||
|
use App\Models\Texture;
|
||
|
use App\Events\GetAvatarPreview;
|
||
|
use Illuminate\Http\UploadedFile;
|
||
|
use App\Listeners\CacheAvatarPreview;
|
||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||
|
|
||
|
class CacheAvatarPreviewTest extends TestCase
|
||
|
{
|
||
|
use DatabaseTransactions;
|
||
|
|
||
|
public function testHandle()
|
||
|
{
|
||
|
Event::listen(GetAvatarPreview::class, CacheAvatarPreview::class);
|
||
|
|
||
|
$texture = factory(Texture::class)->create();
|
||
|
Storage::disk('textures')
|
||
|
->putFileAs('.', UploadedFile::fake()->image($texture->hash), $texture->hash);
|
||
|
$mock = Mockery::mock('overload:Minecraft');
|
||
|
$mock->shouldReceive('generateAvatarFromSkin')->andReturn(imagecreatetruecolor(1, 1));
|
||
|
|
||
|
event(new GetAvatarPreview($texture, 45));
|
||
|
$this->assertTrue(Cache::has("avatar-{$texture->tid}-45"));
|
||
|
}
|
||
|
}
|