public function testShortHandTypeDefinitions() { $schema = new Schema(array('fields' => array('id' => 'int', 'name' => 'string', 'active' => array('type' => 'boolean', 'default' => true)))); $this->assertEqual('int', $schema->type('id')); $this->assertEqual('string', $schema->type('name')); $this->assertEqual('boolean', $schema->type('active')); $this->assertEqual(array('type' => 'int'), $schema->fields('id')); $this->assertEqual(array('id', 'name', 'active'), $schema->names()); $expected = array('id' => array('type' => 'int'), 'name' => array('type' => 'string'), 'active' => array('type' => 'boolean', 'default' => true)); $this->assertEqual($expected, $schema->fields()); }
protected function _init() { $this->_autoConfig[] = 'handlers'; parent::_init(); }
/** * Initializer function called by the constructor unless the constructor * * @see lithium\core\Object::_init() * @throws ConfigException */ protected function _init() { parent::_init(); if (!$this->_connection) { throw new ConfigException("The `'connection'` option must be set."); } if (!$this->_source && !$this->_model) { throw new ConfigException("The `'model'` or `'source'` option must be set."); } $connections = $this->_classes['connections']; $db = $connections::get($this->_connection); if ($model = $this->_model) { $model::config(array('meta' => array('connection' => $this->_connection))); $this->_source = $this->_source ?: $model::meta('source'); $this->_locked = $this->_locked === null ? $model::meta('locked') : $this->_locked; } if ($this->_locked === null) { if ($db::enabled('schema')) { $this->_locked = true; } else { $this->_locked = false; } } foreach ($this->_config['alters'] as $mode => $values) { foreach ($values as $key => $value) { $this->alter($mode, $key, $value); } } }