Exemple #1
0
 /**
  * Executes the tests depending on $testToRun
  */
 function _runTest()
 {
     // Need to set some get variables as TestManager depends on them
     if (in_array($this->testToRun['section'], $this->plugins)) {
         $_GET['plugin'] = $this->testToRun['section'];
     } elseif (in_array(Inflector::Humanize($this->testToRun['section']), $this->plugins)) {
         $_GET['plugin'] = Inflector::Humanize($this->testToRun['section']);
     } elseif ($this->testToRun['section'] == 'app') {
         $_GET['app'] = true;
     }
     if ($this->testToRun['area'] == 'all') {
         TestManager::runAllTests(new TextReporter());
         return;
     } elseif ($this->testToRun['area'] == 'group') {
         $_GET['group'] == $this->testToRun['file'];
         if (isset($_GET['app'])) {
             TestManager::runGroupTest(ucfirst($_GET['group']), APP_TEST_GROUPS, new TextReporter());
         } elseif (isset($_GET['plugin'])) {
             TestManager::runGroupTest(ucfirst($_GET['group']), APP . 'plugins' . DS . $_GET['plugin'] . DS . 'tests' . DS . 'groups', new TextReporter());
         } else {
             TestManager::runGroupTest(ucfirst($_GET['group']), CORE_TEST_GROUPS, new TextReporter());
         }
         return;
     } else {
         $_GET['case'] = 'cases' . DS . $this->testToRun['type'] . DS . $this->testToRun['file'] . '.test.php';
         TestManager::runTestCase($_GET['case'], new TextReporter());
         return;
     }
 }
    public function _missing_table($table = null)
    {
        $tableNotExist = array();
        $tables = array('departments', 'branches', 'designations', 'users', 'employees', 'supplier_registrations', 'products', 'benchmarks');
        foreach ($tables as $table) {
            $modelName = null;
            $modelName .= Inflector::Classify($table);
            $this->loadModel($modelName);
            $this->{$modelName}->recursive = -1;
            $tableExist = $this->{$modelName}->find('first', array('conditions' => array('publish' => 1)));
            if (empty($tableExist)) {
                $tableNotExist[] = $table;
            }
        }
        if (empty($tableNotExist)) {
            return true;
        } else {
            $this->set('tableNotExist', $tableNotExist);
        }
        $this->set($tableNotExist);
        $this->set('install', true);
        if ($tableNotExist[0] == 'benchmarks') {
            $getLink = Router::url('/', true) . $tableNotExist[0];
        } else {
            $getLink = Router::url('/', true) . $tableNotExist[0] . '/lists';
        }
        $this->Session->setFlash('Please add details for <h4>' . Inflector::Humanize($tableNotExist[0]) . ' <a href="' . $getLink . '" class="btn btn-sm btn-success">Add new</a></h4>
					before you start using the application.You can also import these records if you have them ready. <br />
					<strong>Please not that you will have to publish records which you are importing before you can access those records.</strong>
					<br />List of required tables are  Departments, Branches, Designations, Users, Employees, Suppliers, Devices, Products, Benchmarks');
        if (!in_array($this->params->controller, $tables, true)) {
            if ($tableNotExist[0] == '/benchmarks') {
                $this->redirect(array('controller' => $tableNotExist[0], 'action' => 'index'));
            } else {
                $this->redirect(array('controller' => $tableNotExist[0], 'action' => 'index'));
            }
        }
    }
Exemple #3
0
 /**
  * Sets some get vars needed for TestManager
  *
  * @return void
  * @access private
  */
 function __setGetVars()
 {
     if (in_array($this->category, $this->plugins)) {
         $_GET['plugin'] = $this->category;
     } elseif (in_array(Inflector::Humanize($this->category), $this->plugins)) {
         $_GET['plugin'] = Inflector::Humanize($this->category);
     } elseif ($this->category == 'app') {
         $_GET['app'] = true;
     }
     if ($this->type == 'group') {
         $_GET['group'] = true;
     }
 }
 function go($Plugin, $confirmed = false, $stuffList = array(), $excludeList = array())
 {
     $this->plugin = $Plugin;
     $this->PluginName = Inflector::Camelize($Plugin);
     // Plugin App controller handled seperately
     array_push($excludeList, 'plugins' . DS . $this->plugin . DS . $this->plugin . '_app_controller.php');
     // Include the components used to download the plugin, in the hope that other's might do the same :)
     array_push($stuffList, APP . 'controllers' . DS . 'components' . DS . 'download_plugin.php');
     array_push($stuffList, APP . 'controllers' . DS . 'components' . DS . 'zip.php');
     uses("Folder");
     if ($confirmed == false) {
         $this->controller->viewPath = '_generic';
         $this->controller->layout = 'flash';
         $this->controller->set('pause', 5);
         $this->controller->set('url', '/' . $this->PluginName . '/' . $this->controller->name . '/' . $this->controller->action . '/confirmed');
         $this->controller->set('message', 'Your download will begin in 5 seconds.');
         $this->controller->set('pluginUnderscore', $Plugin);
         $this->controller->set('pluginCamel', $this->PluginName);
         $this->controller->set('plugin', Inflector::Humanize($Plugin));
         $date = $this->getLastUpdated($Plugin, $stuffList);
         $this->controller->set('last_updated', $date);
         $this->controller->render('download');
         die;
     }
     $Folder = new Folder(APP . "plugins" . DS . $this->plugin . DS);
     $FileList = $Folder->findRecursive();
     $pattern = "@//--Private[^\\@]*//--Private End@U";
     // include adapated app controller
     $pluginApp = file_get_contents(APP . 'plugins' . DS . $this->plugin . DS . $this->plugin . '_app_controller.php');
     $pluginApp = r("<?php", "<?php\r\ninclude('noswad_controller.php');", $pluginApp);
     $pluginApp = r("extends AppController", "extends NoswadController", $pluginApp);
     $pluginApp = preg_replace($pattern, '', $pluginApp);
     $this->Zip->addData($pluginApp, 'plugins' . DS . $this->plugin . DS . $this->plugin . '_app_controller.php');
     // include every file from the stuff list, but put it in the plugin unless it's from the webroot
     foreach ($stuffList as $file) {
         if (strstr($file, APP_DIR)) {
             $relativePath = substr($file, strlen(APP));
             $relativePath = 'plugins' . DS . $this->plugin . DS . $relativePath;
         } else {
             $relativePath = "webroot" . DS . substr($file, strlen(WWW_ROOT));
         }
         if (!in_array($relativePath, $excludeList) && file_exists($file)) {
             $addedFiles[] = $relativePath;
             $FileContents = file_get_contents($file);
             $FileContents = preg_replace($pattern, '', $FileContents);
             $this->Zip->addData($FileContents, $relativePath);
             /*
             		        $this->Zip->addFile(
             	$file,
             					$relativePath
             );
             */
         }
     }
     // include every file from the plugin
     foreach ($FileList as $file) {
         $relativePath = substr($file, strlen(APP));
         if (!in_array($relativePath, $excludeList) && file_exists($file)) {
             $addedFiles[] = $relativePath;
             $FileContents = file_get_contents($file);
             $FileContents = preg_replace($pattern, '', $FileContents);
             $this->Zip->addData($FileContents, $relativePath);
             /*
             		        $this->Zip->addFile(
             	$file,
             					$relativePath
             );
             */
         }
     }
     // include every file from the generic include folder
     if ($this->genericPath) {
         $Folder = new Folder($this->genericPath);
         $FileList = $Folder->findRecursive();
         foreach ($FileList as $file) {
             $relativePath = substr($file, strlen($this->genericPath));
             if ($relativePath != 'read_me.txt') {
                 $relativePath = 'plugins' . DS . $this->plugin . DS . $relativePath;
             }
             if (!in_array($relativePath, $addedFiles)) {
                 // Allow for overriding of included content
                 $this->Zip->addFile($file, $relativePath);
             }
         }
     }
     $this->Zip->forceDownload($this->PluginName . '.zip');
 }