function setUp() { $this->db =& DbFactory :: instance(); $this->db_table_test = DbTableFactory :: create('Test1'); $this->_cleanUp(); }
function testSave() { $result_id = MetadataManager::saveMetadata(1, 'keywords', 'description'); $this->assertNotNull($result_id); $sys_metadata_db_table = DbTableFactory::create('SysMetadata'); $metadata_row = $sys_metadata_db_table->getRowById($result_id); $this->assertTrue(is_array($metadata_row)); $this->assertTrue(isset($metadata_row['object_id'])); $this->assertTrue(isset($metadata_row['keywords'])); $this->assertTrue(isset($metadata_row['description'])); $this->assertEqual($metadata_row['object_id'], 1); $this->assertEqual($metadata_row['keywords'], 'keywords'); $this->assertEqual($metadata_row['description'], 'description'); }
function testSaveMultitypeValue() { $sp =& SysParam :: instance(); $result = $sp->saveParam('param_1', 'float', 123.053); $this->assertNotNull($result); $result = $sp->saveParam('param_1', 'int', 123.053); $this->assertNotNull($result); $db_table =& DbTableFactory :: create('SysParam'); $list = $db_table->getList(); $this->assertEqual(count($list) , 1); $record = current($list); $this->assertEqual($record['type'], 'int'); $this->assertEqual($record['int_value'], 123); $this->assertEqual($record['float_value'],0); $this->assertEqual($record['char_value'],''); $this->assertEqual($record['blob_value'],''); $result = $sp->saveParam('param_1', 'char', 123.053, false); $this->assertNotNull($result); $list = $db_table->getList(); $this->assertEqual(count($list) , 1); $record = current($list); $this->assertEqual($record['type'], 'char'); $this->assertEqual($record['char_value'],'123.053'); $this->assertEqual($record['float_value'],0); $this->assertEqual($record['int_value'], 123); $this->assertEqual($record['blob_value'],''); }
public function createDBTable($table_name) { include_once(LIMB_DIR . '/class/db_tables/DbTableFactory.class.php'); return DbTableFactory :: create($table_name); }
function _insertFakeSysSiteObjectRecords() { $class_db_table = DbTableFactory :: create('SysClass'); $class_db_table->insert(array('id' => 1001, 'class_name' => 'fake_class')); $tree = new MaterializedPathTree(); $db_table =& DbTableFactory :: create('SysSiteObject'); $data = array(); for($i = 6; $i <= 10 ; $i++) { $this->db->sqlInsert('sys_site_object', array( 'id' => $i, 'class_id' => 1001, 'behaviour_id' => $this->behaviour_id, 'identifier' => 'object_' . $i, 'title' => 'object_' . $i . '_title', 'status' => 0, 'locale_id' => 'en', ) ); $values['identifier'] = 'object_' . $i; $values['object_id'] = $i; $tree->createSubNode($this->root_node_id, $values); } }
function testSaveObjectAccessNoAccessorIdsLimit() { $db_table = DbTableFactory::create('SysActionAccess'); //garbage $db_table->insert(array('id' => 1, 'object_id' => 10, 'access' => 1, 'accessor_id' => 100, 'accessor_type' => AccessPolicy::ACCESSOR_TYPE_USER)); $db_table->insert(array('id' => 2, 'object_id' => 11, 'access' => 1, 'accessor_id' => 110, 'accessor_type' => AccessPolicy::ACCESSOR_TYPE_USER)); $db_table->insert(array('id' => 3, 'object_id' => 10, 'access' => 1, 'accessor_id' => 200, 'accessor_type' => AccessPolicy::ACCESSOR_TYPE_USER)); $access = array(10 => array(100 => 1, 110 => 1), 11 => array(100 => 1, 110 => 0)); $this->ac->saveObjectsAccess($access, AccessPolicy::ACCESSOR_TYPE_USER); $access_rows = $db_table->getList('', 'id', null); $this->assertEqual($access_rows, array(array('id' => $access_rows[0]['id'], 'object_id' => 10, 'access' => 1, 'accessor_id' => 100, 'accessor_type' => AccessPolicy::ACCESSOR_TYPE_USER), array('id' => $access_rows[1]['id'], 'object_id' => 10, 'access' => 1, 'accessor_id' => 110, 'accessor_type' => AccessPolicy::ACCESSOR_TYPE_USER), array('id' => $access_rows[2]['id'], 'object_id' => 11, 'access' => 1, 'accessor_id' => 100, 'accessor_type' => AccessPolicy::ACCESSOR_TYPE_USER))); }
function testGetBehaviourAccesssibleActionsOk() { $authorizer = new SimpleAuthorizerTestVersion($this); $authorizer->expectOnce('getUserAccessorIds'); $authorizer->setReturnValue('getUserAccessorIds', array(100, 200)); $behaviour_id = 10; $db_table = DbTableFactory::create('SysActionAccess'); $db_table->insert(array('id' => 1, 'behaviour_id' => $behaviour_id, 'action_name' => 'create', 'accessor_id' => 100, 'accessor_type' => AccessPolicy::ACCESSOR_TYPE_GROUP)); $db_table->insert(array('id' => 2, 'behaviour_id' => $behaviour_id, 'action_name' => 'delete', 'accessor_id' => 200, 'accessor_type' => AccessPolicy::ACCESSOR_TYPE_GROUP)); $db_table->insert(array('id' => 3, 'behaviour_id' => $behaviour_id, 'action_name' => 'edit', 'accessor_id' => 101, 'accessor_type' => AccessPolicy::ACCESSOR_TYPE_GROUP)); $db_table->insert(array('id' => 4, 'behaviour_id' => 12, 'action_name' => 'publich', 'accessor_id' => 101, 'accessor_type' => AccessPolicy::ACCESSOR_TYPE_GROUP)); $result = array('create', 'delete'); $this->assertEqual($authorizer->getBehaviourAccessibleActions($behaviour_id), $result); $authorizer->tally(); }
require_once($project_dir . '/setup.php'); require_once(LIMB_DIR . '/class/db_tables/DbTableFactory.class.php'); require_once(LIMB_DIR . '/tests/lib/ProjectSiteObjectsLoader.class.php'); $site_objects = array(); echo "loading site objects...\n"; $loader = new ProjectSiteObjectsLoader(); if(!$site_objects = $loader->getSiteObjects()) { die("no site objects loaded"); } $class_db_table = DbTableFactory :: create('SysClass'); foreach($site_objects as $object) { $class_id = $object->getClassId(); $class_properties = $object->getClassProperties(); echo "updating " . get_class($object) . "...\n"; if(!isset($class_properties['icon']) || !$class_properties['icon']) $class_properties['icon'] = '/shared/images/generic.gif'; $class_db_table->updateById($class_id, $class_properties); }
function setUp() { $this->image = DbTableFactory :: create('TestImage'); $this->image_variation = DbTableFactory :: create('TestImageVariation'); $this->media = DbTableFactory :: create('TestMedia'); loadTestingDbDump(dirname(__FILE__) . '/../../sql/cascade_delete.sql'); }