2019-03-21 12:44:15 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests;
|
|
|
|
|
|
|
|
use Cache;
|
|
|
|
use Event;
|
|
|
|
use App\Models\Player;
|
|
|
|
use App\Events\GetPlayerJson;
|
|
|
|
use App\Events\PlayerProfileUpdated;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
|
|
|
|
class CachePlayerJsonTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
2019-04-05 09:19:08 +08:00
|
|
|
option(['enable_json_cache' => true]);
|
|
|
|
$provider = new \App\Providers\EventServiceProvider(app());
|
|
|
|
$provider->boot();
|
2019-03-21 12:44:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testRemember()
|
|
|
|
{
|
|
|
|
$player = factory(Player::class)->create();
|
|
|
|
event(new GetPlayerJson($player, Player::CSL_API));
|
|
|
|
$this->assertTrue(Cache::has("json-{$player->pid}-".Player::CSL_API));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testForget()
|
|
|
|
{
|
|
|
|
$player = factory(Player::class)->create();
|
|
|
|
event(new PlayerProfileUpdated($player));
|
|
|
|
Cache::shouldReceive('forget')
|
|
|
|
->with("json-{$player->pid}-".Player::CSL_API)
|
|
|
|
->with("json-{$player->pid}-".Player::USM_API);
|
|
|
|
}
|
|
|
|
}
|