Ejemplo n.º 1
0
 public function testDebug()
 {
     $msg = 'msg de test';
     $expected = '/^\\w+ \\d+ \\d+:\\d+:\\d+ \\[DEBUG\\] ' . $msg . '$/';
     $this->object->debug($msg);
     $file = file(self::$_filename);
     $this->assertRegExp($expected, $file[count($file) - 1]);
 }
Ejemplo n.º 2
0
 /**
  * load all tasks
  *
  * @return void
  * @throws Phigrate_Exception_Argument
  */
 private function _loadAllTasks()
 {
     $this->_logger->debug(__METHOD__ . ' Start');
     if (!isset($this->_tasksDir)) {
         $msg = 'Please: you must specify the directory of tasks!';
         $this->_logger->err($msg);
         throw new Phigrate_Exception_Argument($msg);
     }
     foreach ($this->_tasksDir as $index => $taskDir) {
         $namespaces = scandir($taskDir);
         $this->_logger->debug('Tasks dir[' . $index . ']: ' . $taskDir);
         //$this->_tasks = array();
         foreach ($namespaces as $namespace) {
             //skip over invalid files
             if ($namespace == '.' || $namespace == '..' || !is_dir($taskDir . '/' . $namespace)) {
                 continue;
             }
             $this->_logger->debug('Namespace: ' . $namespace);
             $files = scandir($taskDir . '/' . $namespace);
             foreach ($files as $file) {
                 $ext = substr($file, -4);
                 //skip over invalid files
                 if ($file == '.' || $file == '..' || $ext != '.php') {
                     continue;
                 }
                 $this->_logger->debug('include ' . $namespace . '/' . $file);
                 require_once $taskDir . '/' . $namespace . '/' . $file;
                 $class = Phigrate_Util_Naming::classFromFileName($taskDir . '/' . $namespace . '/' . $file);
                 $refl = new ReflectionClass($class);
                 if ($refl->isInstantiable()) {
                     $this->_logger->debug('className ' . $class);
                     $taskName = Phigrate_Util_Naming::taskFromClassName($class);
                     $this->_logger->debug('TaskName: ' . $taskName);
                     $taskObj = new $class($this->getAdapter());
                     $this->_logger->debug('obj: ' . get_class($taskObj));
                     $this->registerTask($taskName, $taskObj);
                 }
             }
         }
     }
     $this->_logger->debug(__METHOD__ . ' End');
 }
Ejemplo n.º 3
0
 /**
  * verify db config
  *
  * @return void
  * @throws Exception
  */
 private function _verifyDbConfig()
 {
     $this->_logger->debug(__METHOD__ . ' Start');
     $env = $this->_env;
     $configDb = $this->getConfigDb();
     if (!$configDb instanceof Phigrate_Config) {
         $msg = '(' . $env . ') DB is not configured!';
         require_once 'Phigrate/Exception/MissingConfigDb.php';
         throw new Phigrate_Exception_MissingConfigDb('Error: ' . $msg);
     }
     // Check only variable type for create Adapter
     // all other parameters will checked in adapter
     if (!isset($configDb->type)) {
         $msg = '"type" is not set for "' . $env . '" DB in config file';
         $this->_logger->err($msg);
         require_once 'Phigrate/Exception/MissingAdapterType.php';
         throw new Phigrate_Exception_MissingAdapterType('Error: ' . $msg);
     }
     $this->_logger->debug(__METHOD__ . ' End');
 }