protected function setUp()
 {
     parent::setUp();
     set_time_limit(0);
     \Myfox\Lib\AutoLoad::init();
     \Myfox\Lib\AutoLoad::register('myfox\\app', __DIR__ . '/../app');
     \Myfox\Lib\Cache\Apc::cleanAllCache();
 }
Esempio n. 2
0
 /**
  * 自动加载初始化
  *
  * @access public static
  * @return void
  */
 public static function setAutoLoad()
 {
     if (self::$autoloaded) {
         return;
     }
     require_once __DIR__ . '/../lib/autoload.php';
     \Myfox\Lib\AutoLoad::init();
     \Myfox\Lib\AutoLoad::register('myfox\\app', __DIR__);
     self::$autoloaded = true;
 }
 public function test_should_throw_class_not_found_when_class_not_in_file()
 {
     AutoLoad::register('com', __DIR__ . '/autoload/com');
     try {
         $case1 = new \Com\Aleafs\AutoLoadTestCaseClassNameNotMatched();
     } catch (\Exception $e) {
         $this->assertTrue($e instanceof \Myfox\Lib\Exception, 'Exception Type doesn\'t match,');
         $this->assertTrue((bool) preg_match('/^Class "(.+?)" NOT FOUND IN "(.+?)"/is', $e->getMessage()), 'Exception Message doesn\'t match.');
     }
 }
Esempio n. 4
0
 /**
  * 获取一个类的指定实例
  *
  * @access public static
  * @param  String $class
  * @param  String $name
  * @return Object (refferrence)
  */
 public static function &getObject($class)
 {
     $args = func_get_args();
     $class = array_shift($args);
     $index = self::names($class, json_encode($args));
     if (empty(self::$objects[$index])) {
         if (!class_exists($class)) {
             \Myfox\Lib\AutoLoad::callback($class);
         }
         $rf = new \ReflectionClass($class);
         self::$objects[$index] = $rf->newInstanceArgs($args);
     }
     return self::$objects[$index];
 }
Esempio n. 5
0
 protected function setUp()
 {
     parent::setUp();
     \Myfox\Lib\AutoLoad::register('myfox\\test\\factory', __DIR__ . '/factory');
 }