public static function create() { $create_tpt = Cli::addSwitch("t", "Create templates"); $models = Cli::getInputs("models", "Model names to create"); Cli::enableHelp(); $config = Config::getInstance(); $rest = Plugins::get(Plugins::APP_NAME)->getDir() . DIRECTORY_SEPARATOR . self::REQUEST_DIR; System::ensureDir($rest); $ctrl = WWW_DIR . "/app/crud"; System::ensureDir($ctrl); foreach ($models as $model) { $className = ucfirst($model) . "Rest"; $modelClass = ucfirst($model) . "Model"; Cli::pinfo(" * " . $className); $filename = $rest . "/" . $className . ".class.php"; $tpt = new Template(array("className" => $className, "model" => $model, "umodel" => ucfirst($model), "modelClass" => $modelClass)); if (!file_exists($filename)) { $f = fopen($filename, "w"); fwrite($f, $tpt->parse("crud-rest-skel.php")); fclose($f); } $filename = $ctrl . "/" . $className . ".js"; if (!file_exists($filename)) { $f = fopen($filename, "w"); fwrite($f, $tpt->parse("crud-app-skel.php")); fclose($f); } if ($create_tpt) { $templates = Plugins::get(Plugins::APP_NAME)->getDir() . DIRECTORY_SEPARATOR . Template::TEMPLATES_DIR; System::ensureDir($templates); $afields = $config->get("model." . $model); $fields = array(); foreach ($afields as $name => $prop) { $fields[$name] = new ModelField($model, $name, $prop); } $options = self::defaultOptions(); $tpt = new Template(array_merge($options, array("model" => $fields))); $filename = $templates . "/" . $model . "-crud-list.php"; if (!file_exists($filename)) { $f = fopen($filename, "w"); fwrite($f, $tpt->parse($options["list_partial"])); fclose($f); } $filename = $templates . "/" . $model . "-crud-detail.php"; if (!file_exists($filename)) { $f = fopen($filename, "w"); fwrite($f, $tpt->parse($options["detail_partial"])); fclose($f); } } } }
public static function runtests() { Cli::pinfo("Running tests"); ErrorHandler::unregister(); // Create Suite foreach (Plugins::get_plugins() as $name) { $result = new PHPUnit_Framework_TestResult(); $listner = new self($name); $result->addListener($listner); $plugin = Plugins::get($name); $dir = $plugin->getDir() . DIRECTORY_SEPARATOR . self::TESTS_DIR; if (is_dir($dir)) { foreach (glob($dir . DIRECTORY_SEPARATOR . "*.test.php") as $file) { require_once $file; $testclassname = __NAMESPACE__ . "\\" . substr(basename($file), 0, -9) . "Test"; $suite = new PHPUnit_Framework_TestSuite(new ReflectionClass($testclassname)); $suite->run($result); } } if ($listner->dot) { Cli::pcolorln(Cli::ansiinfo, "]"); } } }