array('title'=> "Text 001", 'type' => 'text', 'writeParms'=>array('size'=>'xlarge')), // 'text_002' etc.. add other configurations with type='text' in here. 'number_001' => array('title'=> "Number 001", 'type' => 'number', 'writeParms'=>array('min'=>0)), // 'number_002' => array('title'=> "Number 002", 'type' => 'number', 'inline'=>true, 'writeParms'=>array('min'=>0)), 'bool_001' => array('title'=> "Bool 001", 'type' => 'bool', 'writeParms'=>array('size'=>'xlarge')), // 'bool_002' => array('title'=> "Bool 002", 'type' => 'bool', 'inline'=>true, 'readParms' => array ('enabled'=>'TÉMA', 'disabled'=>'ČLÁNOK'), 'writeParms' => array ('enabled'=>'TÉMA', 'disabled'=>'ČLÁNOK'), ), 'dropdown_001' => array('title'=>'Dropdown 001', 'type'=>'dropdown', 'tab'=>1, 'writeParms' => array('optArray'=>array('opt_value_1'=>'Label 1', 'opt_value_2'=>'Label 2')) ), 'dropdown_002' => array( 'title' => 'Dropdown 002', 'type' => 'dropdown', 'width' => 'auto', 'readonly' => false, 'filter' => true, 'thclass' => 'center', 'class' => 'center', 'writeParms' => array( 'empty' => 0, 'optArray' => array( 0 => "Option 0", 1 => "Option 1", 2 => "Option 2" ), ), 'readParms' => array( 'optArray' => array( 0 => "Option 0", 1 => "Option 1", 2 => "Option 2" ), ), 'tab' => 0, ), 'textarea_001' => array('title'=> "Textarea 001", 'type' => 'textarea', 'writeParms'=>array('size'=>'xlarge','rows'=> 5)), 'layout_001' => array ( 'title' => 'Layouts 001', 'type' => 'layouts', 'writeParms' => 'plugin=news&id=news_view&merge=1' ), // 'news', 'news_view', 'front' 'layout_002' => array ( 'title' => 'Layouts 002', 'type' => 'layouts', 'writeParms'=>array('plugin'=>'news', 'id'=>'news_view', 'area'=> 'front', 'merge'=>false)), // 'news', 'news_view', 'front' 'image_001' => array('title'=>"Image 001", 'type' => 'image', 'inline'=>false, 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60&legacyPath={e_FILE}downloadimages', 'readonly'=>TRUE, 'batch' => FALSE, 'filter'=>FALSE), 'image_002' => array('title'=>"Image 002", 'type' => 'image', 'inline'=>false, 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60&legacyPath={e_FILE}downloadimages', 'readonly'=>TRUE, 'batch' => FALSE, 'filter'=>FALSE), 'checkboxes_001' => array('title'=>'Checkboxes', 'type'=>'checkboxes', 'writeParms'=>array('optArray'=>array(1=>'Check Opt 1', 2=>'Check Opt 2', 3=>'Check Opt 3', 4=>''))), 'country_001' => array('title'=>'Country', 'type'=>'country'), 'country_002' => array('title'=>'Country', 'type'=>'country'), 'ip_001' => array('title'=>'IP', 'type'=>'ip', 'inline'=>false), 'templates_001' => array('title'=>'Templates', 'type'=>'templates', 'writeParms'=>array('plugin'=>'forum')), 'radio_001' => array('title'=>'Radio', 'type'=>'radio', 'writeParms'=>array('optArray'=>array(1=>'Radio Opt 1', 2=>'Radio Opt 2', 3=>'Radio Opt 3'))), 'tags_001' => array('title'=>'Tags', 'type'=>'tags'), 'bbarea_001' => array('title'=>'BBarea', 'type'=>'bbarea', 'inline'=>false), 'icon_001' => array('title'=>'Icon', 'type'=>'icon', 'inline'=>false), // 'media_001' => array('title'=>'Media', 'type'=>'media', 'inline'=>false), 'file_001' => array('title'=>'File', 'type'=>'file', 'inline'=>false), 'files_001' => array('title'=>'Files', 'type'=>'files', 'data'=> 'json', 'inline'=>false), 'datestamp_001' => array('title'=>'Datestamp', 'type'=>'datestamp', 'inline'=>false), 'date_001' => array('title'=>'Date', 'type'=>'date'), 'userclass_001' => array('title'=>'Userclass', 'type'=>'userclass'), 'userclasses_001' => array('title'=>'Userclasses', 'type'=>'userclasses'), 'user_001' => array('title'=>'User', 'type'=>'user'), 'url_001' => array('title'=>'URL', 'type'=>'url', 'inline'=>false), 'email_001' => array('title'=>'Email', 'type'=>'email', 'inline'=>false), 'hidden_001' => array('title'=>'Hidden', 'type'=>'hidden', 'inline'=>false), // 'method_001' => array('title'=>'Method' , 'type'=>'method', 'inline'=>false), 'language_001' => array('title'=>'Language' , 'type'=>'language'), 'userclass_002' => array('title'=>'Userclass', 'type'=>'userclass', 'writeParms'=>array('default'=>255 /* e_UC_NOBODY*/)), 'media_001' => array('title'=>'Media', 'type'=>'media', 'data'=>'json', 'inline'=>false), 'dropdown_003' => array ( 'title' => 'Location', 'type' => 'dropdown', 'data' => 'safestr', 'tab' => 2, 'inline' => false, 'readParms' => array ( 'type' => 'checkboxes', ), 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'batch' => true, 'filter' => true, 'table' => 'news', 'alias' => 'n.news_render_type', 'field' => 'news_render_type', '__tableField' => 'n.news_render_type', '__tableFrom' => '`#news`.news_render_type AS n.news_render_type', 'writeParms' => array ( 'optArray' => array ( 0 => 'Default Area', 1 => 'Default Area - Title', 4 => 'Default Area - Title/Summary', 2 => 'Sidebar - Othernews', 3 => 'Sidebar - Othernews 2', 5 => 'Carousel', 6 => 'News Grid Menu', ), 'multiple' => 1, 'empty'=>'0' ), ), 'dropdown_004' => array ( 'title' => 'Robots', 'type' => 'dropdown', 'data' => 'safestr', 'tab' => 1, 'inline' => false, 'readParms' => array ( 'type' => 'checkboxes', ), 'writeParms' => array ( 'multiple' => 1, 'optArray' => array ( 'noindex' => 'NoIndex', 'nofollow' => 'NoFollow', 'noarchive' => 'NoArchive', 'noimageindex' => 'NoImageIndex', ), 'title' => array ( 'noindex' => 'Prevent search engines from indexing this item.', 'nofollow' => 'Prevent search engines from following links in this item.', 'noarchive' => 'Prevent cached copies of this item from appearing in search results.', 'noimageindex' => 'Prevent search engines from indexing images of this item.', ), ), 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'batch' => true, 'filter' => true, 'table' => 'news', 'alias' => 'n.news_meta_robots', 'field' => 'news_meta_robots', '__tableField' => 'n.news_meta_robots', '__tableFrom' => '`#news`.news_meta_robots AS n.news_meta_robots', ) , // 'lanlist_001' => array('title'=>'Lanlist' , 'type'=>'lanlist', 'inline'=>false), ); // simulated database/form values. protected $_values = array( 'text_001' => 'some text', 'number_001' => 555, 'number_002' => 444, 'bool_001' => 1, 'bool_002' => 1, 'dropdown_001' => 'opt_value_2', 'dropdown_002' => '2', 'dropdown_003' => '', 'dropdown_004' => '', 'textarea_001' => "the quick brown fox jumps over the lazy dog", 'layout_001' => 'default', 'layout_002' => 'default', 'image_001' => '{e_THEME}bootstrap3/images/e107_adminlogo.png', 'image_002' => 'butterfly.jpg', 'checkboxes_001' => '2,3', 'country_001' => 'au', 'country_002' => '', 'ip_001' => '::1', 'templates_001' => 'mytemplate', 'radio_001' => 2, 'tags_001' => 'keyword1,keyword2,keyword3', 'bbarea_001' => '[html]bold[/html]', 'icon_001' => '{e_IMAGE}e107_icon_32.png', 'file_001' => '{e_MEDIA_FILE}test.zip', 'files_001' => '[ { "path": "{e_MEDIA_FILE}test.zip", "name": "test.zip", "id": "171" }, { "path": "", "name": "", "id": "" }, { "path": "", "name": "", "id": "" }, { "path": "", "name": "", "id": "" }, { "path": "", "name": "", "id": "" } ]', 'datestamp_001' => 1699048024, 'date_001' => '2018-08-23', 'userclass_001' => 0, 'userclasses_001' => '0,1', 'user_001' => 1, 'url_001' => 'https://e107.org', 'email_001' => 'me@email.com', 'hidden_001' => 'hidden-value', 'method_001' => 'custom-value', 'language_001' => 'fr', 'userclass_002' => '', 'media_001' => '[ { "path": "{e_MEDIA_IMAGE}2020-12\/logo_alone_1050.jpg" }, { "path": "{e_MEDIA_IMAGE}2020-12\/no1.png" }, ]' // 'lanlist_001' => 'German', ); protected function _before() { e107::loadAdminIcons(); try { $this->_frm = e107::getForm(); // $this->_frm->__construct(); } catch (Exception $e) { self::fail("Couldn't load e_form object"); } e107::getParser()->setFontAwesome(5); e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php'); e107::includeLan(e_PLUGIN.'forum/languages/English/English_front.php'); include_once(e_PLUGIN.'forum/forum_class.php'); require_once(e_PLUGIN.'forum/templates/forum_icons_template.php'); $legacyDir = APP_PATH."/e107_files/downloadimages/"; $legacyFile = APP_PATH."/e107_files/downloadimages/butterfly.jpg"; if(!is_dir($legacyDir)) { mkdir($legacyDir, 0775, true); } if(!file_exists($legacyFile)) { copy(APP_PATH."/e107_plugins/gallery/images/butterfly.jpg", $legacyFile); } if(!file_exists($legacyFile)) { self::fail("Couldn't copy legacy image 'butterfly.jpg' to e107_files folder"); } } protected function _after() { unlink(APP_PATH."/e107_files/downloadimages/butterfly.jpg"); } /* public function testAddWarning() { } public function testOpen() { } public function testClose() { } public function testCountry() { } */ public function testGetCountry() { $tests = array( array('value'=>'', 'expected'=>''), array('value'=>'au', 'expected'=>'Australia') ); foreach($tests as $t) { $actual = $this->_frm->getCountry($t['value']); self::assertEquals($t['expected'], $actual); } // return array. $actual = $this->_frm->getCountry(); self::assertArrayHasKey('au',$actual); } public function testHelp() { $result = $this->_frm->help('my tip'); self::assertSame("
my tip
", $result); } /* public function testGetRequiredString() { } public function testSetRequiredString() { } public function testTags() { } */ public function testTabs() { $array = [ 0 => ['caption'=> 'Cap 0', 'text'=>'Text 0'], 1 => ['caption'=> 'Cap 1', 'text'=>'Text 1'], ]; // Test 1 $opt = ['active'=>'1', 'fade'=>true]; $result = $this->_frm->tabs($array,$opt); self::assertStringContainsString('_frm->tabs($array,$opt); self::assertStringContainsString(''slide2']; $array = [ 'slide1' => ['caption'=> 'Cap 0', 'text'=>'Text 0'], 'slide2' => ['caption'=> 'Cap 1', 'text'=>'Text 1'], ]; $result = $this->_frm->tabs($array,$opt); self::assertStringContainsString('