You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PhalApi_Cache_Multi_Test.php 1.6 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * PhpUnderControl_PhalApiCacheMulti_Test
  4. *
  5. * 针对 ../../PhalApi/Cache/Multi.php PhalApi_Cache_Multi 类的PHPUnit单元测试
  6. *
  7. * @author: dogstar 20150226
  8. */
  9. require_once dirname(__FILE__) . '/../test_env.php';
  10. if (!class_exists('PhalApi_Cache_Multi')) {
  11. require dirname(__FILE__) . '/../../PhalApi/Cache/Multi.php';
  12. }
  13. class PhpUnderControl_PhalApiCacheMulti_Test extends PHPUnit_Framework_TestCase
  14. {
  15. public $phalApiCacheMulti;
  16. protected function setUp()
  17. {
  18. parent::setUp();
  19. $this->phalApiCacheMulti = new PhalApi_Cache_Multi();
  20. $fileCache = new PhalApi_Cache_File(array('path' => dirname(__FILE__)));
  21. $this->phalApiCacheMulti->addCache($fileCache);
  22. }
  23. protected function tearDown()
  24. {
  25. }
  26. /**
  27. * @group testAddCache
  28. */
  29. public function testAddCache()
  30. {
  31. $cache = new PhalApi_Cache_None();
  32. $rs = $this->phalApiCacheMulti->addCache($cache);
  33. }
  34. /**
  35. * @group testSet
  36. */
  37. public function testSet()
  38. {
  39. $key = 'multiKey';
  40. $value = 'haha~';
  41. $expire = '100';
  42. $rs = $this->phalApiCacheMulti->set($key, $value, $expire);
  43. }
  44. /**
  45. * @group testGet
  46. * @depends testSet
  47. */
  48. public function testGet()
  49. {
  50. $key = 'multiKey';
  51. $rs = $this->phalApiCacheMulti->get($key);
  52. $this->assertSame('haha~', $rs);
  53. }
  54. /**
  55. * @group testDelete
  56. */
  57. public function testDelete()
  58. {
  59. $key = 'multiKey';
  60. $rs = $this->phalApiCacheMulti->delete($key);
  61. }
  62. }