菜谱项目

IlluminateCacheAdapterTest.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * This file is part of jwt-auth.
  4. *
  5. * (c) Sean Tymon <tymon148@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Tymon\JWTAuth\Test\Providers\Storage;
  11. use Mockery;
  12. use Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter;
  13. class IlluminateCacheAdapterTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function setUp()
  16. {
  17. $this->cache = Mockery::mock('Illuminate\Cache\CacheManager');
  18. $this->storage = new IlluminateCacheAdapter($this->cache);
  19. $this->cache->shouldReceive('tags')->andReturn(Mockery::self());
  20. }
  21. public function tearDown()
  22. {
  23. Mockery::close();
  24. }
  25. /** @test */
  26. public function it_should_add_the_item_to_storage()
  27. {
  28. $this->cache->shouldReceive('tags->put')->with('foo', 'bar', 10);
  29. $this->storage->add('foo', 'bar', 10);
  30. }
  31. /** @test */
  32. public function it_should_check_if_the_item_exists_in_storage()
  33. {
  34. $this->cache->shouldReceive('tags->has')->with('foo')->andReturn(true);
  35. $this->assertTrue($this->storage->has('foo'));
  36. }
  37. /** @test */
  38. public function it_should_remove_the_item_from_storage()
  39. {
  40. $this->cache->shouldReceive('tags->forget')->with('foo')->andReturn(true);
  41. $this->assertTrue($this->storage->destroy('foo'));
  42. }
  43. /** @test */
  44. public function it_should_remove_all_items_from_storage()
  45. {
  46. $this->cache->shouldReceive('tags->flush')->withNoArgs();
  47. $this->storage->flush();
  48. }
  49. }