RedisStoreTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Illuminate\Tests\Integration\Cache;
  3. use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
  4. use Illuminate\Support\Facades\Cache;
  5. use Orchestra\Testbench\TestCase;
  6. class RedisStoreTest extends TestCase
  7. {
  8. use InteractsWithRedis;
  9. protected function setUp(): void
  10. {
  11. parent::setUp();
  12. $this->setUpRedis();
  13. }
  14. protected function tearDown(): void
  15. {
  16. parent::tearDown();
  17. $this->tearDownRedis();
  18. }
  19. public function testItCanStoreInfinite()
  20. {
  21. Cache::store('redis')->clear();
  22. $result = Cache::store('redis')->put('foo', INF);
  23. $this->assertTrue($result);
  24. $this->assertSame(INF, Cache::store('redis')->get('foo'));
  25. $result = Cache::store('redis')->put('bar', -INF);
  26. $this->assertTrue($result);
  27. $this->assertSame(-INF, Cache::store('redis')->get('bar'));
  28. }
  29. public function testItCanStoreNan()
  30. {
  31. Cache::store('redis')->clear();
  32. $result = Cache::store('redis')->put('foo', NAN);
  33. $this->assertTrue($result);
  34. $this->assertNan(Cache::store('redis')->get('foo'));
  35. }
  36. }