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.
 
 
 
 
 
 

66 lines
1.3 KiB

  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * PhpUnderControl_PhalApiCookie_Test
  5. *
  6. * 针对 ../../../PhalApi/PhalApi/Cookie.php PhalApi_Cookie 类的PHPUnit单元测试
  7. *
  8. * @author: dogstar 20150411
  9. */
  10. require_once dirname(__FILE__) . '/test_env.php';
  11. if (!class_exists('PhalApi_Cookie')) {
  12. require dirname(__FILE__) . '/../../../PhalApi/PhalApi/Cookie.php';
  13. }
  14. class PhpUnderControl_PhalApiCookie_Test extends PHPUnit_Framework_TestCase
  15. {
  16. public $phalApiCookie;
  17. protected function setUp()
  18. {
  19. parent::setUp();
  20. $this->phalApiCookie = new PhalApi_Cookie();
  21. }
  22. protected function tearDown()
  23. {
  24. }
  25. /**
  26. * @group testGet
  27. */
  28. public function testGet()
  29. {
  30. $key = NULL;
  31. $rs = $this->phalApiCookie->get($key);
  32. $this->assertTrue(is_array($rs));
  33. $this->assertNull($this->phalApiCookie->get('noThisKey'));
  34. $_COOKIE['aKey'] = 'phalapi';
  35. $key = 'aKey';
  36. $this->assertEquals('phalapi', $this->phalApiCookie->get($key));
  37. }
  38. /**
  39. * @group testSet
  40. */
  41. public function testSet()
  42. {
  43. $key = 'bKey';
  44. $value = '2015';
  45. $rs = @$this->phalApiCookie->set($key, $value);
  46. //should not get in this time, but next time
  47. $this->assertNull($this->phalApiCookie->get($key));
  48. }
  49. }