/** * * Setup; runs before each test method. * */ public function setup() { $this->_sql = Solar::factory('Solar_Sql', array('adapter' => 'Solar_Sql_Adapter_Sqlite', 'name' => ':memory:')); // forcibly add sql to registry Solar_Registry::set('sql', $this->_sql); $cmd = "CREATE TABLE acl (" . " flag VARCHAR(10)," . " type CHAR(100)," . " name VARCHAR(255)," . " class_name VARCHAR(255)," . " action_name VARCHAR(255)," . " position VARCHAR(255)" . ")"; $this->_sql->query($cmd); $dir = Solar_Class::dir('Test_Solar_Access_Adapter', '_support'); $lines = file_get_contents($dir . 'access.txt'); $rows = explode("\n", $lines); $pos = 0; foreach ($rows as $row) { $row = trim($row); // skip empty lines and comments if (empty($row) || substr($row, 0, 1) == '#') { continue; } $row = preg_replace('/[ \\t]{2,}/', ' ', $row); $row = explode(' ', $row); $data['flag'] = trim($row[0]); $data['type'] = trim($row[1]); $data['name'] = trim($row[2]); $data['class_name'] = trim($row[3]); $data['action_name'] = trim($row[4]); $data['position'] = $pos; $this->_sql->insert('acl', $data); $pos++; } parent::setup(); }
/** * * Overrides the general Solar_App setup so that we don't need a * database connection. This is because we want the simplest * possible hello-world example. * * Thanks, Clay Loveless, for suggesting this. * * @return void * */ protected function _setup() { // register a Solar_User object if not already. // this will trigger the authentication process. if (!Solar_Registry::exists('user')) { Solar_Registry::set('user', Solar::factory('Solar_User')); } // set the layout title $this->layout_head['title'] = get_class($this); }
/** * * Setup; runs before each test method. * */ public function setup() { parent::setup(); // set up an SQL connection $this->_sql = Solar::factory('Solar_Sql', $this->_sql_config); // set up a model catalog $this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', $this->_catalog_config); // register the connection and catalog Solar_Registry::set('sql', $this->_sql); Solar_Registry::set('model_catalog', $this->_catalog); }
/** * * Setup; runs before each test method. * */ public function setup() { parent::setup(); // set up an SQL connection $this->_sql = Solar::factory('Solar_Sql', $this->_sql_config); $this->_sql->setProfiling(true); // set up a model catalog $this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', $this->_catalog_config); // register the connection and catalog Solar_Registry::set('sql', $this->_sql); Solar_Registry::set('model_catalog', $this->_catalog); // populate everything $this->_populateAll(); }
/** * * Setup; runs before each test method. * */ public function preTest() { parent::preTest(); // set up an SQL connection $this->_sql = Solar::factory('Solar_Sql', $this->_sql_config); $this->_sql->setProfiling(true); // set up a model catalog $this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', $this->_catalog_config); // register the connection and catalog Solar_Registry::set('sql', $this->_sql); Solar_Registry::set('model_catalog', $this->_catalog); // fixture to populate tables $this->_fixture = Solar::factory('Fixture_Solar_Sql_Model'); }
/** * * Post-construction tasks to complete object construction. * * @return void * */ protected function _postConstruct() { parent::_postConstruct(); setcookie($this->_config['cookie'], null, 1); $this->_session = Solar::factory('Solar_Session', array('class' => 'Solar_Log_Adapter_Chromephp')); if (Solar_Registry::exists('chromephp_data')) { $this->_obj = Solar_Registry::get('chromephp_data'); } else { $this->_obj = new StdClass(); $this->_obj->data = array(); $this->_obj->backtrace = array(); $this->_obj->labels = array(); $this->_obj->version = $this->_config['version']; Solar_Registry::set('chromephp_data', $this->_obj); } }
/** * * Setup; runs before each test method. * */ public function setup() { parent::setup(); // set up an SQL connection $this->_sql = Solar::factory('Solar_Sql', $this->_sql_config); $this->_sql->setProfiling(true); // set up a model catalog $this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', $this->_catalog_config); // register the connection and catalog Solar_Registry::set('sql', $this->_sql); Solar_Registry::set('model_catalog', $this->_catalog); // set the class name for relateds $len = strlen('Test_'); $this->_class = substr(get_class($this), $len); // populate everything $this->_populateAll(); }
/** * * Setup; runs before each test method. * */ public function preTest() { parent::preTest(); // set up an SQL connection $this->_sql = Solar::factory('Solar_Sql', $this->_sql_config); // set up a model catalog $this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', $this->_catalog_config); // register the connection and catalog Solar_Registry::set('sql', $this->_sql); Solar_Registry::set('model_catalog', $this->_catalog); // fixture to populate tables $this->_fixture = Solar::factory('Fixture_Solar_Sql_Model'); $this->_fixture->setup(); // preload all models to get discovery out of the way $this->_catalog->users; $this->_catalog->prefs; $this->_catalog->areas; $this->_catalog->nodes; $this->_catalog->metas; $this->_catalog->tags; $this->_catalog->taggings; $this->_catalog->comments; $this->_sql->setProfiling(true); }
/** * * Starts Solar: loads configuration values and and sets up the environment. * * Note that this method is overloaded; you can pass in different * value types for the $config parameter. * * * `null|false` -- This will not load any new configuration values; * you will get only the default [[Solar::$config]] array values defined * in the Solar class. * * * `string` -- The string is treated as a path to a Solar.config.php * file; the return value from that file will be used for [[Solar_Config::load()]]. * * * `array` -- This will use the passed array for the [[Solar_Config::load()]] * values. * * * `object` -- The passed object will be cast as an array, and those * values will be used for [[Solar_Config::load()]]. * * Here are some examples of starting with alternative configuration parameters: * * {{code: php * require_once 'Solar.php'; * * // don't load any config values at all * Solar::start(); * * // point to a config file (which returns an array) * Solar::start('/path/to/another/config.php'); * * // use an array as the config source * $config = array( * 'Solar' => array( * 'ini_set' => array( * 'error_reporting' => E_ALL, * ), * ), * ); * Solar::start($config); * * // use an object as the config source * $config = new StdClass; * $config->Solar = array( * 'ini_set' => array( * 'error_reporting' => E_ALL, * ), * ); * Solar::start($config); * }} * * @param mixed $config The configuration source value. * * @return void * * @see Solar::cleanGlobals() * */ public static function start($config = null) { // don't re-start if we're already running. if (Solar::$_status) { return; } // make sure these classes are loaded $list = array('Base', 'Class', 'Config', 'File'); $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Solar'; foreach ($list as $name) { // don't use the autoloader when checking for existence if (!class_exists('Solar_' . $name, false)) { require $dir . DIRECTORY_SEPARATOR . "{$name}.php"; } } // register autoloader spl_autoload_register(array('Solar_Class', 'autoload')); // clear out registered globals if (ini_get('register_globals')) { Solar::cleanGlobals(); } // load config values Solar_Config::load($config); // make sure we have the Solar arch-class configs $arch_config = Solar_Config::get('Solar'); if (!$arch_config) { Solar_Config::set('Solar', null, Solar::$_Solar); } else { Solar_Config::set('Solar', null, array_merge(Solar::$_Solar, (array) $arch_config)); } // set the system directory Solar::$system = Solar_Config::get('Solar', 'system'); // process ini settings from config file $settings = Solar_Config::get('Solar', 'ini_set', array()); foreach ($settings as $key => $val) { ini_set($key, $val); } // user-defined registry entries $register = Solar_Config::get('Solar', 'registry_set', array()); foreach ($register as $name => $list) { // make sure we have the class-name and a config $list = array_pad((array) $list, 2, null); list($spec, $config) = $list; // register the item Solar_Registry::set($name, $spec, $config); } // Solar itself needs these default objects registered ... $name_class = array('inflect' => 'Solar_Inflect', 'locale' => 'Solar_Locale', 'rewrite' => 'Solar_Uri_Rewrite', 'request' => 'Solar_Request', 'response' => 'Solar_Http_Response'); // ... but only if not already registered by the user. foreach ($name_class as $name => $class) { if (!Solar_Registry::exists($name)) { Solar_Registry::set($name, $class); } } // run any 'start' hooks $hooks = Solar_Config::get('Solar', 'start', array()); Solar::callbacks($hooks); // and we're done! Solar::$_status = true; }
/** * * Sets up the Solar_App environment. * * Registers 'sql', 'user', and 'content' objects, and sets the * layout title to the class name. * * @return void * */ protected function _setup() { // register a Solar_Sql object if not already if (!Solar_Registry::exists('sql')) { Solar_Registry::set('sql', Solar::factory('Solar_Sql')); } // register a model catalog if not already if (!Solar_Registry::exists('model_catalog')) { Solar_Registry::set('model_catalog', Solar::factory('Solar_Sql_Model_Catalog')); } // register a Solar_User object if not already. // this will trigger the authentication process. if (!Solar_Registry::exists('user')) { Solar_Registry::set('user', Solar::factory('Solar_User')); } // set the layout title $this->layout_head['title'] = get_class($this); // retain the model catalog $this->_model = Solar_Registry::get('model_catalog'); }
/** * * Setup; runs before each test method. * */ public function preTest() { parent::preTest(); Solar_Registry::set('sql', 'Solar_Sql'); }
/** * * Setup; runs before each test method. * */ public function setup() { parent::setup(); Solar_Registry::set('sql', 'Solar_Sql'); Solar_Registry::set('model_catalog', 'Solar_Sql_Model_Catalog'); }
/** * * Setup; runs before each test method. * */ public function setup() { parent::setup(); Solar_Registry::set('sql', 'Solar_Sql'); }
public function testDependency_registry() { $expect = Solar::factory('Mock_Solar_Example'); Solar_Registry::set('example', $expect); $actual = Solar::dependency('Mock_Solar_Example', 'example'); $this->assertSame($actual, $expect); }