mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-21 06:19:38 +08:00
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use Cache;
|
|
use Event;
|
|
use App\Events;
|
|
use App\Models\Player;
|
|
use Illuminate\Http\UploadedFile;
|
|
use App\Listeners\CachePlayerExists;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
class CachePlayerExistsTest extends TestCase
|
|
{
|
|
use DatabaseTransactions;
|
|
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
Event::subscribe(CachePlayerExists::class);
|
|
}
|
|
|
|
public function testRemember()
|
|
{
|
|
$player = factory(Player::class)->create();
|
|
Cache::shouldReceive('get')
|
|
->times(2)
|
|
->andReturn(null)
|
|
->andReturn(null);
|
|
Cache::shouldReceive('forever')->once()->with('notfound-nope', '1');
|
|
|
|
event(new Events\CheckPlayerExists(null));
|
|
event(new Events\CheckPlayerExists($player->name));
|
|
event(new Events\CheckPlayerExists('nope'));
|
|
}
|
|
|
|
public function testForget()
|
|
{
|
|
$player = factory(Player::class)->create();
|
|
event(new Events\PlayerWasAdded($player));
|
|
Cache::shouldReceive('forget')->with("notfound-{$player->name}");
|
|
}
|
|
}
|