ue = e107::getUserExt(); // $this->make('e107_user_extended'); } catch(Exception $e) { $this->assertTrue(false, "Couldn't load e107_user_extended object"); } $this->structTypes = array( 'text' => EUF_TEXT, 'homepage' => EUF_TEXT, 'radio' => EUF_RADIO, 'dropdown' => EUF_DROPDOWN, 'dbfield' => EUF_DB_FIELD, 'textarea' => EUF_TEXTAREA, 'integer' => EUF_INTEGER, 'date' => EUF_DATE, 'language' => EUF_LANGUAGE, 'list' => EUF_PREDEFINED, 'checkbox' => EUF_CHECKBOX, 'predefined' => EUF_PREFIELD, // Used in plugin installation routine. 'addon' => EUF_ADDON, 'country' => EUF_COUNTRY, 'richtextarea' => EUF_RICHTEXTAREA, ); $this->structLabels = array ( 'text' => 'Text', 'homepage' => 'UE_LAN_HOMEPAGE', // test constant use as well. 'radio' => 'Radio', 'dropdown' => 'Dropdown', 'dbfield' => 'Dbfield', 'textarea' => 'Textarea', 'integer' => 'Integer', 'date' => 'Date', 'language' => 'Language', 'list' => 'List', 'checkbox' => 'Checkbox', 'predefined' => 'Predefined', 'country' => 'Country', 'richtextarea' => 'Richtextarea', 'addon' => 'Addon' ); $this->structValues = array( 'dropdown' => 'drop1,drop2,drop3', 'dbfield' => 'core_media_cat,media_cat_id,media_cat_title,media_cat_order', 'list' => 'timezones', 'radio' => 'M => UE_LAN_MALE,F => UE_LAN_FEMALE', 'checkbox' => 'check1,check2,check3', 'addon' => e107::serialize( array('type'=> 'number', 'data' => 'int', 'title' => $this->structLabels['addon']), 'json') ); $this->structDefault = array( 'dropdown' => 'drop2', 'dbfield' => '3', // 'list' => 'timezones', 'radio' => 'F', 'checkbox' => 'check2' ); $this->structParent = array( 'list' => 16, 'radio' => 16, 'textarea' => 16, 'country' => 17, ); $this->structRequired = array( 'text' => 1, 'homepage' => 0, // test constant use as well. 'radio' => 1, 'dropdown' => 1, 'dbfield' => 1, 'textarea' => 0, 'integer' => 1, 'date' => 1, 'language' => 1, 'list' => 1, 'checkbox' => 1, 'predefined' => 1, 'country' => 1, 'richtextarea' => 1, 'addon' => 1 ); // clear the table. $sql = e107::getDb(); $sql->truncate('user_extended_struct'); // Add a field of each type. foreach($this->structTypes as $k=> $v) { $value = (isset($this->structValues[$k])) ? $this->structValues[$k] : null; $insert = array( 'name' => $k, 'text' => $this->structLabels[$k], 'type' => $v, 'parms' => null, 'values' => (isset($this->structValues[$k])) ? $this->structValues[$k] : null, 'default' => (isset($this->structDefault[$k])) ? $this->structDefault[$k] : null, 'parent' => (isset($this->structParent[$k])) ? $this->structParent[$k] : 0, 'required' => (isset($this->structRequired[$k])) ? $this->structRequired[$k] : 0, 'read' => e_UC_MEMBER, 'write' => e_UC_ADMIN, 'applicable' => e_UC_MAINADMIN, ); // simulate data from e_user.php 'settings' method. if($v === EUF_ADDON) { $insert['fieldType'] = 'int(2)'; $insert['parms'] = '_blank'; // plugin dir. } $this->ue->user_extended_add($insert); // $this->ue->user_extended_add($k, ucfirst($k), $v , null, $value); } // Insert a User-Extended Category $insertCategory = array( 'name' => 'mycategory', 'text' => 'Category Name', 'type' => 0, 'read' => e_UC_PUBLIC, 'write' => e_UC_ADMIN, 'applicable' => e_UC_MEMBER, 'order' => 1, ); if($this->ue->user_extended_add($insertCategory) === false) { trigger_error("failed to create user-extended category"); } // Insert a User-Extended Category $insertCategory2 = array( 'name' => 'mycategory2 ', 'text' => 'Category Name 2', 'type' => 0, 'read' => e_UC_ADMIN, 'write' => e_UC_ADMIN, 'applicable' => e_UC_MEMBER, 'order' => 2, ); if($this->ue->user_extended_add($insertCategory2) === false) { trigger_error("failed to create user-extended category"); } // As $_POSTED. $this->userValues = array( 'text' => 'Some Text', 'homepage' => 'https://e107.org', 'radio' => 'M', 'dropdown' => 'drop3', 'dbfield' => '5', 'textarea' => 'Text area value', 'integer' => 21, 'date' => '2001-01-11', 'language' => 'English', 'list' => 'America/Aruba', 'checkbox' => array ( 0 => 'value2', 1 => 'value3'), 'predefined' => 'predefined', // Used in plugin installation routine. // 'addon' => EUF_ADDON, 'country' => 'us', 'richtextarea' => 'Rich text', ); $this->ue->init(); } public function testSetGet() { // set them all first. foreach($this->userValues as $field => $value) { $this->ue->set(1, $field, $value); // set user extended value for user_id: 1. } foreach($this->userValues as $field => $value) { $result = $this->ue->get(1, $field); // retrieve value for $field of user_id: 1. $this->assertSame($this->userValues[$field], $result); } } /** * FIXME - has problems with shuffling. */ /*public function testUserextendedCatShortcode() { $sc = e107::getScBatch('usersettings'); $sc->reset(); $perms = array(e_UC_PUBLIC, e_UC_MEMBER, e_UC_ADMIN, e_UC_MAINADMIN); $sc->setVars(array('userclass_list' => implode(',',$perms))); $cat = (int) e107::getDb()->retrieve('user_extended_struct', 'user_extended_struct_id', "user_extended_struct_name = 'mycategory' LIMIT 1"); $result = $sc->sc_userextended_cat($cat); $this->assertStringContainsString('

Category Name

', $result); $this->assertStringContainsString("