MemcachedTests.php 1020 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. use League\Flysystem\Cached\Storage\Memcached;
  3. use PHPUnit\Framework\TestCase;
  4. class MemcachedTests extends TestCase
  5. {
  6. public function testLoadFail()
  7. {
  8. $client = Mockery::mock('Memcached');
  9. $client->shouldReceive('get')->once()->andReturn(false);
  10. $cache = new Memcached($client);
  11. $cache->load();
  12. $this->assertFalse($cache->isComplete('', false));
  13. }
  14. public function testLoadSuccess()
  15. {
  16. $response = json_encode([[], ['' => true]]);
  17. $client = Mockery::mock('Memcached');
  18. $client->shouldReceive('get')->once()->andReturn($response);
  19. $cache = new Memcached($client);
  20. $cache->load();
  21. $this->assertTrue($cache->isComplete('', false));
  22. }
  23. public function testSave()
  24. {
  25. $response = json_encode([[], []]);
  26. $client = Mockery::mock('Memcached');
  27. $client->shouldReceive('set')->once()->andReturn($response);
  28. $cache = new Memcached($client);
  29. $cache->save();
  30. }
  31. }