Merge branch 'master' of http://git.roojs.com/Pman.Core
[Pman.Core] / UpdateDatabase.php
index d5dd966..a05fe06 100644 (file)
@@ -753,16 +753,24 @@ class Pman_Core_UpdateDatabase extends Pman
                 if (empty($data['test_class'])) {
                     $this->jerr("missing test_class for template $name");
                 }
-                $cm->test_class = $cm;
+                $cm->test_class = $data['test_class'];
             }
             require_once $cm->test_class . '.php';
+            
             $clsname = str_replace('/','_', $cm->test_class);
-            $method = new ReflectionMethod($clsname , 'test_'. $name) ;
-            if (!$method->isStatic()) {
+            try {
+                $method = new ReflectionMethod($clsname , 'test_'. $name) ;
+                $got_it = $method->isStatic();
+            } catch(Exception $e) {
+                $got_it = false;
+                
+            }
+            if (!$got_it) {
                 $this->jerr("template {$name} does not have a test method {$clsname}::test_{$name}");
             }
-            if ($up) {
+            if ($update) {
                 $cm->update($old);
+                echo "email: {$name} - checked\n";
                 continue; /// we do not import the body content of templates that exist...
             } else {
                 $cm->insert();
@@ -773,15 +781,17 @@ class Pman_Core_UpdateDatabase extends Pman
             
             $opts = array(
                 'update' => 1,
-                'file' => $mail_template_dir. $name .'.html'
+                'file' => $templateDir. $name .'.html'
             );
             
             if (!empty($data['master'])) {
-                $opts['master'] = $mail_template_dir . $master .'.html';
+                $opts['master'] = $templateDir . $master .'.html';
             }
             require_once 'Pman/Core/Import/Core_email.php';
             $x = new Pman_Core_Import_Core_email();
             $x->get('', $opts);
+            
+            echo "email: {$name} - CREATED\n";
         }
     }