protected function doFixture($method) { $name = $this->name === "" ? get_class($this) : $this->name; $fixtureDir = RUN_BASE . DS . "tests" . DS . "fixture"; $reflection = new Sabel_Reflection_Class($name); $annotation = $reflection->getAnnotation("fixture"); if (isset($annotation[0])) { if ($method === "downFixture") { $annotation[0] = array_reverse($annotation[0]); } try { foreach ($annotation[0] as $fixtureName) { Sabel::fileUsing($fixtureDir . DS . $this->getFixturePath($fixtureName), true); $className = "Fixture_" . $fixtureName; $fixture = new $className(); $fixture->{$method}(); } } catch (Exception $e) { if ($reflection->hasMethod($method . "Exception")) { $reflection->getMethod($method . "Exception")->invoke(null, $e); } else { throw $e; } } } }
public function getProcessors() { $baseDir = RUN_BASE . DS . LIB_DIR_NAME . DS . "processor" . DS; foreach (array_keys($this->processors) as $name) { Sabel::fileUsing($baseDir . ucfirst($name) . ".php", true); } return $this->processors; }
public static function suite() { $bus = new Sabel_Bus(); Sabel::fileUsing(dirname(__FILE__) . DS . "paginators" . DS . "Base.php", true); $suite = new self(); $suite->add("Paginators_Status"); $suite->add("Paginators_Follower"); return $suite; }
public static function suite() { Sabel::fileUsing(dirname(__FILE__) . DS . "models" . DS . "Base.php", true); $suite = new self(); $suite->add("Models_User"); $suite->add("Models_Status"); $suite->add("Models_Request"); $suite->add("Models_Follower"); return $suite; }
public static function suite() { Sabel::fileUsing(dirname(__FILE__) . DS . "logics" . DS . "Base.php", true); $suite = new self(); $suite->add("Logics_Register"); $suite->add("Logics_Status"); $suite->add("Logics_Follow"); $suite->add("Logics_User"); return $suite; }
/** * @param string $mdlName * * @return array */ public static function getColumnNames($mdlName) { if (defined("MODELS_DIR_PATH")) { Sabel::fileUsing(MODELS_DIR_PATH . DS . $mdlName . ".php", true); } if (isset(self::$columnNames[$mdlName])) { return self::$columnNames[$mdlName]; } else { return array(); } }
public function execute($bus) { Sabel_Db_Config::initialize($bus->getConfig("database")); Sabel::fileUsing(RUN_BASE . DS . LIB_DIR_NAME . DS . "db" . DS . "utility.php", true); if (!defined("SBL_BATCH")) { // start session. $session = $bus->get("session"); $session->start(); l("START SESSION: " . $session->getName() . "=" . $session->getId()); } // default page title. $bus->get("response")->setResponse("pageTitle", "Phwittr"); // $request = $bus->get("request"); // if ($request->isPost()) $this->trim($request); }
public function execute($bus) { $destination = $bus->get("destination"); $moduleName = $destination->getModule(); $controllerName = $destination->getController(); $sharedHelper = "application"; $commonHelpers = MODULES_DIR_PATH . DS . HELPERS_DIR_NAME; $moduleHelpers = MODULES_DIR_PATH . DS . $moduleName . DS . HELPERS_DIR_NAME; $helpers = array(); $helpers[] = $commonHelpers . DS . $sharedHelper; $helpers[] = $moduleHelpers . DS . $sharedHelper; $helpers[] = $moduleHelpers . DS . $controllerName; foreach ($helpers as $helper) { Sabel::fileUsing($helper . ".php", true); } }
public function add($testName) { $dir = RUN_BASE . DS . "tests" . DS . "functional" . DS; $parts = explode("_", $testName); $last = array_pop($parts); if (count($parts) > 0) { $dir .= strtolower(implode(DS, $parts)) . DS; } $className = "Functional_" . $testName; Sabel::fileUsing($dir . $last . ".php", true); $reflection = new ReflectionClass($className); if ($reflection->isSubClassOf("Sabel_Test_TestSuite")) { $this->addTest($reflection->getMethod("suite")->invoke(null)); } else { $this->addTest(new self($className)); } }
public function run() { if (count($this->arguments) < 2) { $this->usage(); exit; } $method = $this->getFixtureMethod(); $this->defineEnvironment($this->arguments[0]); Sabel_Db_Config::initialize(new Config_Database()); if (Sabel_Console::hasOption("export", $this->arguments)) { unset($this->arguments[array_search("--export", $this->arguments, true)]); return $this->export("fixture"); } elseif (Sabel_Console::hasOption("export-csv", $this->arguments)) { $dir = Sabel_Console::getOption("export-csv", $this->arguments); if ($dir === null) { $dir = RUN_BASE . DS . "data"; } return $this->export("csv", $dir); } $fixtureName = $this->arguments[1]; if ($fixtureName === "all") { foreach (scandir(FIXTURE_DIR) as $item) { if ($item === "." || $item === "..") { continue; } Sabel::fileUsing(FIXTURE_DIR . DS . $item, true); $className = "Fixture_" . substr($item, 0, strlen($item) - 4); $instance = new $className(); $instance->initialize(); $instance->{$method}(); } } else { $filePath = FIXTURE_DIR . DS . $fixtureName . ".php"; if (Sabel::fileUsing($filePath, true)) { $className = "Fixture_" . $fixtureName; $instance = new $className(); $instance->initialize(); $instance->{$method}(); $this->success(ucfirst($method) . " " . $fixtureName); } else { $this->error("no such fixture file. '{$filePath}'"); } } }
public function setUp() { if (self::$setup) { return; } $dir = TEST_APP_DIR . DS . LIB_DIR_NAME . DS . "processor" . DS; Sabel::fileUsing($dir . "Addon.php", true); Sabel::fileUsing($dir . "Session.php", true); Sabel::fileUsing($dir . "Executer.php", true); Sabel::fileUsing($dir . "Helper.php", true); Sabel::fileUsing($dir . "Initializer.php", true); Sabel::fileUsing($dir . "Controller.php", true); Sabel::fileUsing($dir . "Response.php", true); Sabel::fileUsing($dir . "Request.php", true); Sabel::fileUsing($dir . "Router.php", true); Sabel::fileUsing($dir . "View.php", true); unshift_include_paths(array(MODULES_DIR_NAME, LIB_DIR_NAME, MODULES_DIR_NAME . DS . "models", ADDON_DIR_NAME), TEST_APP_DIR . DS); self::$setup = true; }
public function getTest($suiteClassName, $suiteClassFile = "", $syntaxCheck = true) { Sabel::fileUsing($suiteClassFile, true); $testClass = new ReflectionClass($suiteClassName); if ($testClass->hasMethod(self::SUITE_METHODNAME)) { $suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME); if (!$suiteMethod->isStatic()) { throw new Sabel_Exception_Runtime("suite() method must be static."); } try { $test = $suiteMethod->invoke(NULL, $testClass->getName()); } catch (ReflectionException $e) { $message = sprintf("Failed to invoke suite() method.\n%s", $e->getMessage()); throw new Sabel_Exception_Runtime($message); } } else { $test = new Sabel_Test_TestSuite($testClass); } $this->clearStatus(); return $test; }
define("SBL_LOG_ERR", 0x8); define("SBL_LOG_ALL", 0xff); ############################################################ define("TPL_SUFFIX", ".tpl"); define("DS", DIRECTORY_SEPARATOR); define("NO_REWRITE_PREFIX", "_uri"); define("MODULES_DIR_NAME", "app"); define("VIEW_DIR_NAME", "views"); define("HELPERS_DIR_NAME", "helpers"); define("LIB_DIR_NAME", "lib"); define("ADDON_DIR_NAME", "addon"); define("CONFIG_DIR_PATH", RUN_BASE . DS . "config"); define("MODULES_DIR_PATH", RUN_BASE . DS . MODULES_DIR_NAME); define("MODELS_DIR_PATH", MODULES_DIR_PATH . DS . "models"); define("LOG_DIR_PATH", RUN_BASE . DS . "logs"); define("CACHE_DIR_PATH", RUN_BASE . DS . "cache"); define("COMPILED_DIR_PATH", CACHE_DIR_PATH . DS . "templates"); define("DEFAULT_LAYOUT_NAME", "layout"); ################# INCLUDE_PATH SETTINGS #################### unshift_include_paths(array(MODULES_DIR_PATH, RUN_BASE . DS . LIB_DIR_NAME, MODELS_DIR_PATH, RUN_BASE . DS . ADDON_DIR_NAME)); unshift_include_path(Sabel::getPath()); ############### INCLUDE CONFIGURATION FILES ################ Sabel::fileUsing(CONFIG_DIR_PATH . DS . "Bus.php", true); Sabel::fileUsing(CONFIG_DIR_PATH . DS . "Map.php", true); Sabel::fileUsing(CONFIG_DIR_PATH . DS . "Addon.php", true); Sabel::fileUsing(CONFIG_DIR_PATH . DS . "Database.php", true); Sabel::fileUsing(CONFIG_DIR_PATH . DS . "Mail.php", true); Sabel::fileUsing(CONFIG_DIR_PATH . DS . "DI.php", true); ################## APPLICATION CONSTANTS ################### define("DEFAULT_IMAGE_NAME", "default.png"); define("FRIENDS_ICON_LIMIT", 36);
public static function suite() { Sabel::fileUsing(PROCESSORS_DIR . DS . "Controller.php", true); return self::createSuite("Test_Processor_Controller"); }
<?php Sabel::fileUsing("tasks" . DS . "Tests.php", true); /** * UnitTest * * @category Sakle * @package org.sabel.sakle * @author Mori Reo <*****@*****.**> * @author Ebine Yutaka <*****@*****.**> * @copyright 2004-2008 Mori Reo <*****@*****.**> * @license http://www.opensource.org/licenses/bsd-license.php BSD License */ class UnitTest extends Tests { public function run() { Sabel_Db_Config::initialize(new Config_Database()); $runner = Sabel_Test_Runner::create(); $runner->setClassPrefix("Unit_"); $testsDir = RUN_BASE . DS . "tests" . DS . "unit"; if (count($this->arguments) === 0) { foreach (scandir($testsDir) as $file) { if (preg_match("/^[A-Z].+\\.php\$/", $file)) { $testName = str_replace(".php", "", $file); $runner->start($testName, $testsDir . DS . $file); } } } else { $testName = $this->arguments[0]; $runner->start($testName, $testsDir . DS . $testName . ".php");
public static function suite() { Sabel::fileUsing(PROCESSORS_DIR . DS . "Request.php", true); return self::createSuite("Test_Processor_Request"); }
function MODEL($mdlName, $id = null) { static $cache = array(); if (isset($cache[$mdlName])) { if ($cache[$mdlName]) { return new $mdlName($id); } else { return new Sabel_Db_Model_Proxy($mdlName, $id); } } if (!($exists = class_exists($mdlName, false))) { $path = MODELS_DIR_PATH . DS . $mdlName . ".php"; $exists = Sabel::fileUsing($path, true); } $cache[$mdlName] = $exists; if ($exists) { return new $mdlName($id); } else { return new Sabel_Db_Model_Proxy($mdlName, $id); } }
define("SBL_LOG_INFO", 0x1); define("SBL_LOG_DEBUG", 0x2); define("SBL_LOG_WARN", 0x4); define("SBL_LOG_ERR", 0x8); define("SBL_LOG_ALL", 0xff); ############################################################ define("TPL_SUFFIX", ".tpl"); define("DS", DIRECTORY_SEPARATOR); define("MODULES_DIR_NAME", "app"); define("VIEW_DIR_NAME", "views"); define("HELPERS_DIR_NAME", "helpers"); define("LIB_DIR_NAME", "lib"); define("ADDON_DIR_NAME", "addon"); define("CONFIG_DIR_PATH", RUN_BASE . DS . "config"); define("MODULES_DIR_PATH", RUN_BASE . DS . MODULES_DIR_NAME); define("MODELS_DIR_PATH", MODULES_DIR_PATH . DS . "models"); define("LOG_DIR_PATH", RUN_BASE . DS . "logs"); define("CACHE_DIR_PATH", RUN_BASE . DS . "cache"); define("COMPILED_DIR_PATH", CACHE_DIR_PATH . DS . "templates"); define("APP_ENCODING", mb_internal_encoding()); define("DEFAULT_LAYOUT_NAME", "layout"); ################# INCLUDE_PATH SETTINGS #################### unshift_include_paths(array(MODULES_DIR_PATH, RUN_BASE . DS . LIB_DIR_NAME, MODELS_DIR_PATH, RUN_BASE . DS . ADDON_DIR_NAME)); unshift_include_path(Sabel::getPath()); ############### INCLUDE CONFIGURATION FILES ################ Sabel::fileUsing(CONFIG_DIR_PATH . DS . "Bus.php", true); Sabel::fileUsing(CONFIG_DIR_PATH . DS . "Map.php", true); Sabel::fileUsing(CONFIG_DIR_PATH . DS . "Addon.php", true); Sabel::fileUsing(CONFIG_DIR_PATH . DS . "Database.php", true); Sabel::fileUsing(CONFIG_DIR_PATH . DS . "Container.php", true);