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.
 
 
 
 
 
 

92 lines
1.8 KiB

  1. <?php
  2. /**
  3. * PhpUnderControl_PhalApiLoader_Test
  4. *
  5. * 针对 ../PhalApi/Loader.php PhalApi_Loader 类的PHPUnit单元测试
  6. *
  7. * @author: dogstar 20141004
  8. */
  9. require_once dirname(__FILE__) . '/test_env.php';
  10. if (!class_exists('PhalApi_Loader')) {
  11. require dirname(__FILE__) . '/../PhalApi/Loader.php';
  12. }
  13. class PhpUnderControl_PhalApiLoader_Test extends PHPUnit_Framework_TestCase
  14. {
  15. public $coreLoader;
  16. protected function setUp()
  17. {
  18. parent::setUp();
  19. $this->coreLoader = DI()->loader;
  20. }
  21. protected function tearDown()
  22. {
  23. }
  24. /**
  25. * @group testAddDirs
  26. */
  27. public function testAddDirs()
  28. {
  29. $dirs = array('FirstDir', 'SecondDir');
  30. $this->coreLoader->addDirs($dirs);
  31. }
  32. /**
  33. * @group testSetBasePath
  34. */
  35. public function testSetBasePath()
  36. {
  37. $path = PHALAPI_ROOT;
  38. $rs = $this->coreLoader->setBasePath($path);
  39. }
  40. /**
  41. * @group testLoadFile
  42. */
  43. public function testLoadFile()
  44. {
  45. $filePath = dirname(__FILE__) . '/test_file_for_loader.php';
  46. $this->coreLoader->loadFile($filePath);
  47. }
  48. /**
  49. * @group testLoad
  50. */
  51. public function testLoad()
  52. {
  53. $className = 'PhalApi_Api';
  54. $rs = $this->coreLoader->load($className);
  55. }
  56. public function testLoadOnce()
  57. {
  58. $obj = new PhalApi_Logger_File('./', 0);
  59. }
  60. public function testRegisterAgain()
  61. {
  62. $loader = new PhalApi_Loader('./', array());
  63. $loader = new PhalApi_Loader('./', array());
  64. $obj = new PhalApi_DB_NotORM(array());
  65. }
  66. public function testConstructAndAdd()
  67. {
  68. $loader = new PhalApi_Loader('./', array('./Config'));
  69. $loader->addDirs('./Data');
  70. $loader->addDirs(array('./Crypt'));
  71. }
  72. }