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, 'writeParms'=>array('size'=>'xlarge')),
'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,
'inline' => true,
'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', 'inline' => false, 'writeParms' => 'plugin=news&id=news_view&merge=1' ), // 'news', 'news_view', 'front'
'layout_002' => array ( 'title' => 'Layouts 002', 'type' => 'layouts', 'inline' => true, 'writeParms'=>array('plugin'=>'news', 'id'=>'news_view', 'area'=> 'front', 'merge'=>false)), // 'news', 'news_view', 'front'
// 'layout_003' => array ( 'title' => 'Layouts 003', 'type' => 'layouts', 'inline' => true, 'writeParms'=>array('plugin'=>'news', 'id'=>'news_view', 'area'=> 'front', 'merge'=>false)), // 'news', 'news_view', 'front'
'image_001' => array('title'=>"Image 001", 'type' => 'image', '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 001", 'type' => 'image', '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),
);
// 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',
'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',
);
protected function _before()
{
try
{
$this->_frm = $this->make('e_form');
$this->_frm->__construct();
}
catch (Exception $e)
{
$this->assertTrue(false, "Couldn't load e_form object");
}
$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))
{
$this->assertTrue(false,"Couldn't copy legacy image 'butterfly.jpg' to e107_files folder");
}
}
protected function _after()
{
}
/*
public function testAddWarning()
{
}
public function testOpen()
{
}
public function testClose()
{
}
public function testCountry()
{
}
public function testGetCountry()
{
}
public function testGetRequiredString()
{
}
public function testSetRequiredString()
{
}
public function testTags()
{
}
public function testTabs()
{
}
public function testCarousel()
{
}
public function testUrl()
{
}
public function testText()
{
}
public function testNumber()
{
}
public function testEmail()
{
}
public function testIconpreview()
{
}
public function testIconpicker()
{
}
public function testAvatarpicker()
{
}
public function testImagepicker()
{
}
public function testFilepicker()
{
}*/
public function testDatepicker()
{
date_default_timezone_set('UTC');
$time = strtotime('January 1st, 2018 1am');
$actual = $this->_frm->datepicker('date_field',$time,'type=datetime&format=MM, dd, yyyy hh:ii');
$expected = "";
$this->assertEquals($expected, $actual);
// test timezone change...
date_default_timezone_set('America/Los_Angeles');
$actual = $this->_frm->datepicker('date_field',$time,'type=datetime&format=MM, dd, yyyy hh:ii');
$expected = "";
$this->assertEquals($expected, $actual);
}
/*
public function testUserlist()
{
}
public function testUserpicker()
{
}
public function testRate()
{
}
public function testLike()
{
}
public function testFile()
{
}
public function testUpload()
{
}
public function testPassword()
{
}
public function testPagination()
{
}
public function testProgressBar()
{
}
public function testTextarea()
{
}
public function testBbarea()
{
}
public function testCheckbox()
{
}
public function testCheckboxes()
{
}
public function testCheckbox_label()
{
}
public function testCheckbox_switch()
{
}
public function testCheckbox_toggle()
{
}
public function testUc_checkbox()
{
}
public function test_uc_checkbox_cb()
{
}
public function testUc_label()
{
}
public function testRadio()
{
}
public function testRadio_switch()
{
}
public function testFlipswitch()
{
}
public function testLabel()
{
}
public function testHelp()
{
}
public function testSelect_open()
{
}
public function testSelectbox()
{
}
*/
public function testSelect()
{
$this->_frm->__construct(true);
$options = array('optDisabled'=>array('opt_2'));
$selected = 'opt_3';
$opt_array = array('opt_1'=>"Option 1", 'opt_2'=>"Option 2", 'opt_3'=>"Option 3");
$actual = $this->_frm->select('name', $opt_array, $selected, $options);
$actual = str_replace("\n", "", $actual);
$expected = "";
$this->assertEquals($expected,$actual);
// test group opt-array.
$opt_array = array(
'GROUP 1' => array ('opt_1'=>"Option 1", 'opt_2'=>"Option 2", 'opt_3'=>"Option 3"),
'GROUP 2' => array ('opt_4'=>"Option 4", 'opt_5'=>"Option 5", 'opt_6'=>"Option 6"),
);
$actual = $this->_frm->select('name', $opt_array, $selected, $options);
$expected = "";
$actual = str_replace(array("\n", "\r"), "", $actual);
$expected = str_replace(array("\n", "\r"), "", $expected);
$this->assertEquals($expected,$actual);
}
/*
public function testUserclass()
{
}
public function testSearch()
{
}
*/
public function testUc_select_single_numeric()
{
$uc_options = 'admin';
$select_options = array('multiple' => false);
$opt_options = array();
$actual = $this->_frm->uc_select('uc', 254, $uc_options, $select_options, $opt_options);
$expected = "";
$this->assertEquals($expected, $actual);
}
public function testUc_select_single_string()
{
$uc_options = 'admin';
$select_options = array('multiple' => false);
$opt_options = array();
$actual = $this->_frm->uc_select('uc', 'Admin', $uc_options, $select_options, $opt_options);
$expected = "";
$this->assertEquals($expected, $actual);
}
public function testUc_select_multi_numeric()
{
$uc_options = 'member,admin';
$select_options = array('multiple' => true);
$opt_options = array();
$actual = $this->_frm->uc_select('uc', '254,253', $uc_options, $select_options, $opt_options);
$expected = "";
$this->assertEquals($expected, $actual);
}
public function testUc_select_multi_string()
{
$uc_options = 'member,admin';
$select_options = array('multiple' => true);
$opt_options = array();
$actual = $this->_frm->uc_select('uc', 'Admin,Members', $uc_options, $select_options, $opt_options);
$expected = "";
$this->assertEquals($expected, $actual);
}
public function testUc_select_multi_mixed()
{
$uc_options = 'member,admin';
$select_options = array('multiple' => true);
$opt_options = array();
$actual = $this->_frm->uc_select('uc', 'Admin,253', $uc_options, $select_options, $opt_options);
$expected = "";
$this->assertEquals($expected, $actual);
}
/*
public function test_uc_select_cb()
{
}
public function testOptgroup_open()
{
}
*/
public function testOption()
{
$options = array('disabled'=>true);
$actual = $this->_frm->option('name','value', '', $options);
$expected = "";
$this->assertEquals($expected, $actual);
}
/*
public function testOption_multi()
{
}
public function testOptgroup_close()
{
}
public function testSelect_close()
{
}
public function testHidden()
{
}
public function testToken()
{
}
public function testSubmit()
{
}
public function testSubmit_image()
{
}
public function testAdmin_trigger()
{
}
public function testButton()
{
}
public function testBreadcrumb()
{
}
public function testInstantEditButton()
{
}
public function testAdmin_button()
{
}
public function testDefaultButtonClassExists()
{
}
public function testGetDefaultButtonClassByAction()
{
}
public function testGetNext()
{
}
public function testGetCurrent()
{
}
public function testResetTabindex()
{
}
public function testGet_attributes()
{
}
public function test_format_id()
{
}
public function testName2id()
{
}
public function testFormat_options()
{
}
public function test_default_options()
{
}
public function testColumnSelector()
{
}
public function testColGroup()
{
}
public function testThead()
{
}
public function testRenderHooks()
{
}
public function testRenderRelated()
{
}
public function testRenderTableRow()
{
}
public function testRenderInline()
{
}
*/
public function testRenderValue()
{
$frm = $this->_frm;
$expected = array(
'text_001' => 'some text',
'number_001' => 555,
'number_002' => "444",
'bool_001' => ADMIN_TRUE_ICON,
'bool_002' => "✓",
'dropdown_001' => 'Label 2',
'dropdown_002' => "",
'textarea_001' => "the quick brown fox jumps over the lazy dog",
'layout_001' => 'default',
'layout_002' => "Default",
'image_001' => "
",
'image_002' => "
",
);
foreach($this->_fields as $field=>$att)
{
$value = $this->_values[$field];
$result = $frm->renderValue($field, $value, $att);
if(!isset($expected[$field]))
{
$this->expectExceptionMessage('\$expected value for \$field not set in script');
$this->expectExceptionMessage($result);
}
$this->assertEquals($expected[$field], $result);
}
}
public function testRenderElement()
{
$frm = $this->_frm;
$frm->__construct(true);
$expected = array(
'text_001' => "",
'number_001' => "",
'number_002' => "",
'bool_001' => " ",
'bool_002' => " ",
'dropdown_001' => "",
'dropdown_002' => "",
'textarea_001' => "",
'layout_001' => "",
'layout_002' => "",
'image_001' => "
",
'image_002' => "
",
);
foreach($this->_fields as $field=>$att)
{
$value = $this->_values[$field];
$result = $frm->renderElement($field, $value, $att);
$result = str_replace("\n", "", $result);
// if(empty($expected[$field]))
{
// $this->expectExceptionMessage('\$expected value for \$field not set in script');
// $this->expectExceptionMessage($result);
}
$this->assertEquals($expected[$field], $result);
}
}
/*
public function testRenderListForm()
{
}
public function testRenderGridForm()
{
}
public function testRenderCreateForm()
{
}
public function testRenderCreateFieldset()
{
}
public function testRenderCreateButtonsBar()
{
}
public function testRenderForm()
{
}
public function testRenderFieldset()
{
}
public function testRenderValueTrigger()
{
}
public function testRenderElementTrigger()
{
}*/
}