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.
 
 
 
 
 
 

67 lines
1.3 KiB

  1. <?php
  2. /**
  3. * PhpUnderControl_PhalApiConfigFile_Test
  4. *
  5. * 针对 ../PhalApi/Config/File.php PhalApi_Config_File 类的PHPUnit单元测试
  6. *
  7. * @author: dogstar 20141004
  8. */
  9. require_once dirname(__FILE__) . '/test_env.php';
  10. if (!class_exists('PhalApi_Config_File')) {
  11. require dirname(__FILE__) . '/../PhalApi/Config/File.php';
  12. }
  13. class PhpUnderControl_PhalApiConfigFile_Test extends PHPUnit_Framework_TestCase
  14. {
  15. public $coreConfigFile;
  16. protected function setUp()
  17. {
  18. parent::setUp();
  19. $this->coreConfigFile = DI()->config;
  20. }
  21. protected function tearDown()
  22. {
  23. }
  24. public function testConstruct()
  25. {
  26. $config = new PhalApi_Config_File(dirname(__FILE__) . '/Config');
  27. }
  28. /**
  29. * @group testGet
  30. */
  31. public function testGetDefault()
  32. {
  33. $key = 'sys.noThisKey';
  34. $default = 2014;
  35. $rs = $this->coreConfigFile->get($key, $default);
  36. $this->assertSame($default, $rs);
  37. }
  38. public function testGetNormal()
  39. {
  40. $key = 'sys.debug';
  41. $rs = $this->coreConfigFile->get($key);
  42. $this->assertFalse($rs);
  43. }
  44. public function testGetAll()
  45. {
  46. $key = 'dbs';
  47. $rs = $this->coreConfigFile->get($key);
  48. $this->assertTrue(is_array($rs));
  49. }
  50. }