liteTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. /**
  12. * Lite缓存驱动测试
  13. * @author 刘志淳 <chun@engineer.com>
  14. */
  15. namespace tests\thinkphp\library\think\cache\driver;
  16. use think\Cache;
  17. class liteTest extends \PHPUnit_Framework_TestCase
  18. {
  19. protected function getCacheInstance()
  20. {
  21. return Cache::connect(['type' => 'Lite', 'path' => CACHE_PATH]);
  22. }
  23. /**
  24. * 测试缓存读取
  25. * @return mixed
  26. * @access public
  27. */
  28. public function testGet()
  29. {
  30. $cache = $this->getCacheInstance();
  31. $this->assertFalse($cache->get('test'));
  32. }
  33. /**
  34. * 测试缓存设置
  35. * @return mixed
  36. * @access public
  37. */
  38. public function testSet()
  39. {
  40. $cache = $this->getCacheInstance();
  41. $this->assertNotEmpty($cache->set('test', 'test'));
  42. }
  43. /**
  44. * 删除缓存测试
  45. * @return mixed
  46. * @access public
  47. */
  48. public function testRm()
  49. {
  50. $cache = $this->getCacheInstance();
  51. $this->assertTrue($cache->rm('test'));
  52. }
  53. /**
  54. * 清空缓存测试
  55. * @return mixed
  56. * @access public
  57. */
  58. public function testClear()
  59. {
  60. }
  61. }