protected function setUp()
 {
     parent::setUp();
     $path = new File(getcwd(), Zibo::DIRECTORY_APPLICATION);
     $modelIO = new XmlModelIO();
     $models = $modelIO->readModelsFromPath($path);
     $register = new ModelRegister();
     $register->registerModels($models);
     $models = $register->getModels();
     $definer = new ModelDefiner();
     $definer->defineModels($models);
     $connection = DatabaseManager::getInstance()->getConnection();
     $connection->executeFile(new File(self::SQL_SETUP));
     if ($this->modelName != null) {
         $this->model = ModelManager::getInstance()->getModel($this->modelName);
     }
     Zibo::getInstance()->registerEventListener(Zibo::EVENT_LOG, array($this, 'logSql'));
 }
Example #2
0
 /**
  * Registers all the models defined in the include paths
  * @return array Array with the registered models
  */
 private function registerModels()
 {
     $models = $this->modelReader->readModelsFromIncludePaths();
     $register = new ModelRegister();
     $register->registerModels($models);
     $models = $register->getModels();
     $this->index = array_keys($models);
     $modelManager = ModelManager::getInstance();
     foreach ($models as $model) {
         $modelManager->addModel($model);
     }
     $cache = $modelManager->getModelCache();
     foreach ($models as $model) {
         $meta = $model->getMeta();
         $meta->getProperties();
         // make sure the meta is parsed before caching the model
         $cache->setModel($model);
     }
     return $models;
 }