public function schema($field = null) { $schema = null; switch (true) { case is_object($this->_schema): $schema = $this->_schema; break; case $model = $this->_model: $schema = $model::schema(); break; } if ($schema) { return $field ? $schema->fields($field) : $schema; } return array(); }
public function testSchemaAccess() { $fields = array('foo' => array('type' => 'string')); $schema = new Schema(compact('fields')); $entity = new Entity(compact('schema')); $this->assertEqual($schema, $entity->schema()); }