function test_createMetadataTable() { $app =& Dataface_Application::getInstance(); $sql = "create table `md_test2` (\n\t\t\t\tfname varchar(32) NOT NULL,\n\t\t\t\tlname varchar(32) NOT NULL,\n\t\t\t\tage int(11) default 10,\n\t\t\t\tprimary key (`fname`,`lname`))"; $res = xf_db_query($sql, $app->db()); if (!$res) { trigger_error(xf_db_error($app->db()), E_USER_ERROR); } $mt = new Dataface_MetadataTool('md_test2'); $this->assertTrue($mt->createMetadataTable()); $this->assertEquals(1, xf_db_num_rows(xf_db_query("show tables like 'md_test2__metadata'", $app->db()))); $cols = $mt->getColumns(null, false); $this->assertEquals(array('fname', 'lname', '__translation_state', '__published_state'), array_keys($cols)); }
function test_metadata_from() { $app =& Dataface_Application::getInstance(); $original_value = @$app->_conf['metadata_enabled']; $app->_conf['metadata_enabled'] = 1; import('Dataface/MetadataTool.php'); $mt = new Dataface_MetadataTool('Profiles'); $mt->createMetadataTable(); $builder = new Dataface_QueryBuilder('Profiles'); echo $from = $builder->_from(); $sql = "select * {$from} where id='10'"; //$res = xf_db_query($sql, $app->db()); //if ( !$res ) trigger_error(xf_db_error($app->db()), E_USER_ERROR); }