mirror of
https://github.com/e107inc/e107.git
synced 2025-07-09 17:16:20 +02:00
Merge branch 'master' of https://github.com/e107inc/e107-test
This commit is contained in:
@ -17,6 +17,6 @@
|
|||||||
// $config = e_CORE."xml/default_install.xml";
|
// $config = e_CORE."xml/default_install.xml";
|
||||||
// $ret = e107::getXml()->e107Import($config, 'replace', true, true); // Add core pref values
|
// $ret = e107::getXml()->e107Import($config, 'replace', true, true); // Add core pref values
|
||||||
|
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true); // doing nothing right now.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
119
tests/unit/db_verifyTest.php
Normal file
119
tests/unit/db_verifyTest.php
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2018 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class db_verifyTest extends \Codeception\Test\Unit
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testGetFields()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testClearCache()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRenderNotes()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCompareAll()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRenderTableName()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetId()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetSqlData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetIndex()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCompare()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testToMysql()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRunFix()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRenderTableSelect()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testVerify()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetPrevious()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRenderResults()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testErrors()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetSqlFileTables()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFixForm()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRunComparison()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCompileResults()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetSqlLanguages()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
235
tests/unit/e_dateTest.php
Normal file
235
tests/unit/e_dateTest.php
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2018 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class e_dateTest extends \Codeception\Test\Unit
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $dateObj;
|
||||||
|
|
||||||
|
protected function _before()
|
||||||
|
{
|
||||||
|
// Expected values made using the C locale
|
||||||
|
setlocale(LC_TIME, 'C');
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$this->dateObj = $this->make('e_date');
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
$this->fail("Couldn't load e_date object");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testToMask()
|
||||||
|
{
|
||||||
|
|
||||||
|
$array = array(
|
||||||
|
|
||||||
|
'%Y' => 'yyyy', // jquery-ui docs say 'yy' but yy produces '13' instead of '2013'
|
||||||
|
'%d' => 'dd',
|
||||||
|
'%m' => 'mm',
|
||||||
|
'%B' => 'MM', // Full month name, based on the locale
|
||||||
|
'%A' => 'DD', // A full textual representation of the day
|
||||||
|
|
||||||
|
'%I' => 'HH', // Two digit representation of the hour in 12-hour format
|
||||||
|
'%H' => 'hh', // 24 hour format - leading zero
|
||||||
|
'%y' => 'yy',
|
||||||
|
'%M' => 'ii', // Two digit representation of the minute
|
||||||
|
'%S' => 'ss', // Two digit representation of the second
|
||||||
|
|
||||||
|
'%a' => 'D', // An abbreviated textual representation of the day
|
||||||
|
'%b' => 'M', // Abbreviated month name, based on the locale
|
||||||
|
'%h' => 'M', // Abbreviated month name, based on the locale (an alias of %b)
|
||||||
|
|
||||||
|
'%l' => 'H', // 12 hour format - no leading zero
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'%p' => 'P', // %p UPPER-CASE 'AM' or 'PM' based on the given time
|
||||||
|
'%P' => 'p', // %P lower-case 'am' or 'pm' based on the given time
|
||||||
|
|
||||||
|
|
||||||
|
// '%T' => 'hh:mm:ss',
|
||||||
|
// '%r' => "hh:mmm:ss TT" // 12 hour format
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$keys = array_keys($array);
|
||||||
|
// $values = array_values($array);
|
||||||
|
|
||||||
|
$old = implode(" ",$keys);
|
||||||
|
|
||||||
|
|
||||||
|
$new = $this->dateObj->toMask($old);
|
||||||
|
|
||||||
|
$expected = "yyyy dd mm MM DD HH hh yy ii ss D M M H P p";
|
||||||
|
$this->assertEquals($expected,$new);
|
||||||
|
|
||||||
|
|
||||||
|
$expected = "%Y %d %m %B %A %I %H %y %M %S %a %b %b %l %p %P";
|
||||||
|
$actual = $this->dateObj->toMask($new, true);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$unix = strtotime('December 21, 2012 3:45pm');
|
||||||
|
$strftime = "%A, %d %b, %Y %I:%M %p"; // expected Friday, 21 Dec, 2012 03:45 PM
|
||||||
|
$expected = "Friday, 21 Dec, 2012 03:45 PM";
|
||||||
|
|
||||||
|
// test strtotime mask (default)
|
||||||
|
$actual = $this->dateObj->convert_date($unix, $strftime);
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
// test DateTimePicker mask
|
||||||
|
$datepicker = $this->dateObj->toMask($strftime);
|
||||||
|
$actual2 = $this->dateObj->convert_date($unix, $datepicker);
|
||||||
|
$this->assertEquals($expected, $actual2);
|
||||||
|
|
||||||
|
// test DateTime mask
|
||||||
|
$dateTime= $this->dateObj->toMask($strftime, 'DateTime');
|
||||||
|
$d = new DateTime('@'.$unix);
|
||||||
|
$actual3 = $d->format($dateTime);
|
||||||
|
$this->assertEquals($expected, $actual3);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSupported()
|
||||||
|
{
|
||||||
|
$this->dateObj->supported(); // dumps info
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIsValidTimezone()
|
||||||
|
{
|
||||||
|
// should exists
|
||||||
|
$result = $this->dateObj->isValidTimezone('Europe/Berlin');
|
||||||
|
$this->assertTrue($result);
|
||||||
|
|
||||||
|
// should not exist
|
||||||
|
$result = $this->dateObj->isValidTimezone('Europe/Bonn');
|
||||||
|
$this->assertFalse($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testBuildDateLocale()
|
||||||
|
{
|
||||||
|
$actual = $this->dateObj->buildDateLocale();
|
||||||
|
|
||||||
|
$this->assertContains('$.fn.datetimepicker.dates["en"]', $actual);
|
||||||
|
$this->assertContains('days: ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],', $actual);
|
||||||
|
$this->assertContains('monthsShort: ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],', $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testToTime()
|
||||||
|
{
|
||||||
|
// This tests fail on my machine.
|
||||||
|
// strptime substracts a month which results in the wrong time // BUG?
|
||||||
|
|
||||||
|
$actual = $this->dateObj->toTime('2018/05/13', '%Y/%m/%d');
|
||||||
|
$expected = mktime(0, 0,0,5, 13, 2018);
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
$actual = $this->dateObj->toTime('2018/05/13 20:10', '%Y/%m/%d %H:%M');
|
||||||
|
$expected = mktime(20, 10,0,5, 13, 2018);
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDecodeDateTime()
|
||||||
|
{
|
||||||
|
$actual = $this->dateObj->decodeDateTime('09122003', 'date', 'dmy', false);
|
||||||
|
$expected = mktime(0, 0,0,12, 9, 2003);
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
$actual = $this->dateObj->decodeDateTime('153045', 'time', 'dmy', false);
|
||||||
|
$expected = mktime(15, 30,45,0, 0, 0);
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
$actual = $this->dateObj->decodeDateTime('09122003 153045', 'datetime', 'dmy', false);
|
||||||
|
$expected = mktime(15, 30,45,12, 9, 2003);
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testComputeLapse()
|
||||||
|
{
|
||||||
|
$older = mktime(15, 30,45,12, 9, 2003);
|
||||||
|
$newer = mktime(14, 20,40,12, 11, 2003);
|
||||||
|
$actual = $this->dateObj->computeLapse($older, $newer, false, true, 'long');
|
||||||
|
$expected = '1 day, 22 hours, 49 minutes, 55 seconds ago';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testStrptime()
|
||||||
|
{
|
||||||
|
|
||||||
|
$actual = $this->dateObj->strptime('2018/05/13', '%Y/%m/%d');
|
||||||
|
$expected = array(
|
||||||
|
'tm_year' => 118,
|
||||||
|
'tm_mon' => 4,
|
||||||
|
'tm_mday' => 13,
|
||||||
|
'tm_sec' => 0,
|
||||||
|
'tm_min' => 0,
|
||||||
|
'tm_hour' => 0,
|
||||||
|
'unparsed' => '',
|
||||||
|
'tm_fmon' => 'May',
|
||||||
|
'tm_amon' => 'May',
|
||||||
|
'tm_wday' => 0,
|
||||||
|
'tm_yday' => 132,
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
$actual = $this->dateObj->strptime('2018/05/13 20:10', '%Y/%m/%d %H:%M');
|
||||||
|
$expected = array(
|
||||||
|
'tm_year' => 118,
|
||||||
|
'tm_mon' => 4,
|
||||||
|
'tm_mday' => 13,
|
||||||
|
'tm_hour' => 20,
|
||||||
|
'tm_min' => 10,
|
||||||
|
'tm_sec' => 0,
|
||||||
|
'unparsed' => '',
|
||||||
|
'tm_amon' => 'May',
|
||||||
|
'tm_fmon' => 'May',
|
||||||
|
'tm_wday' => 0,
|
||||||
|
'tm_yday' => 132,
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testConvert_date()
|
||||||
|
{
|
||||||
|
// will probably fail on windows
|
||||||
|
$actual = $this->dateObj->convert_date(mktime(12, 45, 03, 2, 5, 2018), 'long');
|
||||||
|
$expected = 'Monday 05 February 2018 - 12:45:03';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
$actual = $this->dateObj->convert_date(mktime(12, 45, 03, 2, 5, 2018), 'inputtime');
|
||||||
|
$expected = '12:45 PM';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTerms()
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = $this->dateObj->terms();
|
||||||
|
|
||||||
|
$result = ($data[1] === 'January' && $data[12] === 'December') ? true : false;
|
||||||
|
|
||||||
|
$this->assertTrue($result);
|
||||||
|
|
||||||
|
// $this->fail(print_r($result,true));
|
||||||
|
}
|
||||||
|
}
|
@ -26,11 +26,36 @@
|
|||||||
'number_001' => array('title'=> "Number 001", 'type' => 'number', 'writeParms'=>array('min'=>0)),
|
'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)),
|
'number_002' => array('title'=> "Number 002", 'type' => 'number', 'inline'=>true, 'writeParms'=>array('min'=>0)),
|
||||||
|
|
||||||
'bool_001' => array('title'=> "Bool 001", 'type' => 'text', 'writeParms'=>array('size'=>'xlarge')),
|
'bool_001' => array('title'=> "Bool 001", 'type' => 'bool', 'writeParms'=>array('size'=>'xlarge')),
|
||||||
'bool_002' => array('title'=> "Bool 002", 'type' => 'text', 'inline'=>true, '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_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)),
|
'textarea_001' => array('title'=> "Textarea 001", 'type' => 'textarea', 'writeParms'=>array('size'=>'xlarge','rows'=> 5)),
|
||||||
|
|
||||||
@ -80,8 +105,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
/* public function testAddWarning()
|
public function testAddWarning()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -174,13 +199,26 @@
|
|||||||
public function testFilepicker()
|
public function testFilepicker()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public function testDatepicker()
|
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 = "<input class='e-datetime input-xlarge form-control' type='text' size='40' id='e-datepicker-date-field' value='January, 01, 2018 01:00' data-date-unix ='true' data-date-format='MM, dd, yyyy hh:ii' data-date-ampm='false' data-date-language='en' data-date-firstday='0' /><input type='hidden' name='date_field' id='date-field' value='1514768400' />";
|
||||||
|
|
||||||
|
$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 = "<input class='e-datetime input-xlarge form-control' type='text' size='40' id='e-datepicker-date-field' value='December, 31, 2017 17:00' data-date-unix ='true' data-date-format='MM, dd, yyyy hh:ii' data-date-ampm='false' data-date-language='en' data-date-firstday='0' /><input type='hidden' name='date_field' id='date-field' value='1514768400' />";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
/*
|
||||||
public function testUserlist()
|
public function testUserlist()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -310,12 +348,51 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public function testSelect()
|
public function testSelect()
|
||||||
{
|
{
|
||||||
|
$options = array('disabled'=>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 = "<select name='name' id='name' class='tbox select form-control' tabindex='1'><option value='opt_1'>Option 1</option><option value='opt_2' disabled='disabled'>Option 2</option><option value='opt_3' selected='selected'>Option 3</option></select>";
|
||||||
|
|
||||||
|
$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 = "<select name='name' id='name' class='tbox select form-control' tabindex='2'>
|
||||||
|
<optgroup class='optgroup level-1' label='GROUP 1'>
|
||||||
|
<option value='opt_1'>Option 1</option>
|
||||||
|
<option value='opt_2' disabled='disabled'>Option 2</option>
|
||||||
|
<option value='opt_3' selected='selected'>Option 3</option>
|
||||||
|
</optgroup>
|
||||||
|
<optgroup class='optgroup level-1' label='GROUP 2'>
|
||||||
|
<option value='opt_4'>Option 4</option>
|
||||||
|
<option value='opt_5'>Option 5</option>
|
||||||
|
<option value='opt_6'>Option 6</option>
|
||||||
|
</optgroup>
|
||||||
|
|
||||||
|
</select>";
|
||||||
|
|
||||||
|
$actual = str_replace(array("\n", "\r"), "", $actual);
|
||||||
|
$expected = str_replace(array("\n", "\r"), "", $expected);
|
||||||
|
|
||||||
|
$this->assertEquals($expected,$actual);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public function testUserclass()
|
public function testUserclass()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -340,12 +417,17 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public function testOption()
|
public function testOption()
|
||||||
{
|
{
|
||||||
|
$options = array('disabled'=>true);
|
||||||
|
$actual = $this->_frm->option('name','value', '', $options);
|
||||||
|
$expected = "<option value='value' disabled='disabled'>name</option>";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public function testOption_multi()
|
public function testOption_multi()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -502,10 +584,11 @@
|
|||||||
'number_001' => 555,
|
'number_001' => 555,
|
||||||
'number_002' => "<a class='e-tip e-editable editable-click' data-name='number_002' title=\"Edit Number 002\" data-type='text' data-pk='0' data-url='".e_SELF."?mode=&action=inline&id=0&ajax_used=1' href='#'>444</a>",
|
'number_002' => "<a class='e-tip e-editable editable-click' data-name='number_002' title=\"Edit Number 002\" data-type='text' data-pk='0' data-url='".e_SELF."?mode=&action=inline&id=0&ajax_used=1' href='#'>444</a>",
|
||||||
|
|
||||||
'bool_001' => 1,
|
'bool_001' => ADMIN_TRUE_ICON,
|
||||||
'bool_002' => "<a class='e-tip e-editable editable-click' data-emptytext='-' data-name='bool_002' title=\"Edit Bool 002\" data-type='text' data-pk='0' data-url='".e_SELF."?mode=&action=inline&id=0&ajax_used=1' href='#'>1</a>",
|
'bool_002' => "<a class='e-tip e-editable editable-click e-editable-boolean' data-name='bool_002' data-source='{\"0\":\"\u0026cross;\",\"1\":\"\u0026check;\"}' title=\"Edit Bool 002\" data-type='select' data-inputclass='x-editable-bool-002 e-editable-boolean' data-value=\"1\" href='#' data-class='e-editable-boolean' data-url='".e_SELF."?mode=&action=inline&id=0&ajax_used=1'>✓</a>",
|
||||||
|
|
||||||
'dropdown_001' => 'Label 2',
|
'dropdown_001' => 'Label 2',
|
||||||
|
'dropdown_002' => "<a class='e-tip e-editable editable-click ' data-name='dropdown_002' data-source='{\"0\":\"Option 0\",\"1\":\"Option 1\",\"2\":\"Option 2\"}' title=\"Edit Dropdown 002\" data-type='select' data-inputclass='x-editable-dropdown-002 ' data-value=\"\" href='#' data-url='".e_SELF."?mode=&action=inline&id=0&ajax_used=1'></a>",
|
||||||
|
|
||||||
'textarea_001' => "the quick brown fox jumps over the lazy dog",
|
'textarea_001' => "the quick brown fox jumps over the lazy dog",
|
||||||
|
|
||||||
@ -525,6 +608,7 @@
|
|||||||
if(!isset($expected[$field]))
|
if(!isset($expected[$field]))
|
||||||
{
|
{
|
||||||
$this->expectExceptionMessage('\$expected value for \$field not set in script');
|
$this->expectExceptionMessage('\$expected value for \$field not set in script');
|
||||||
|
$this->expectExceptionMessage($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals($expected[$field], $result);
|
$this->assertEquals($expected[$field], $result);
|
||||||
@ -535,6 +619,48 @@
|
|||||||
|
|
||||||
public function testRenderElement()
|
public function testRenderElement()
|
||||||
{
|
{
|
||||||
|
$frm = $this->_frm;
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
'text_001' => "<input type='text' name='text_001' value='some text' maxlength=255 id='text-001' class='tbox form-control input-xlarge' tabindex='1' />",
|
||||||
|
|
||||||
|
'number_001' => "<input type='number' name='number_001' min='0' step='1' value='555' id='number-001' class='tbox number e-spinner input-small form-control' tabindex='2' pattern='^[0-9]*' />",
|
||||||
|
'number_002' => "<input type='number' name='number_002' min='0' step='1' value='444' id='number-002' class='tbox number e-spinner input-small form-control' tabindex='3' pattern='^[0-9]*' />",
|
||||||
|
|
||||||
|
'bool_001' => "<label class='radio-inline'><input type='radio' name='bool_001' value='1' checked='checked' /><span>LAN_ON</span></label> <label class='radio-inline'><input type='radio' name='bool_001' value='0' /><span>LAN_OFF</span></label>",
|
||||||
|
'bool_002' => "<label class='radio-inline'><input type='radio' name='bool_002' value='1' checked='checked' /><span>LAN_ON</span></label> <label class='radio-inline'><input type='radio' name='bool_002' value='0' /><span>LAN_OFF</span></label>",
|
||||||
|
|
||||||
|
|
||||||
|
'dropdown_001' => "<select name='dropdown_001' id='dropdown-001' class='tbox select form-control' tabindex='4'><option value='opt_value_1'>Label 1</option><option value='opt_value_2' selected='selected'>Label 2</option></select>",
|
||||||
|
'dropdown_002' => "<select name='dropdown_002' id='dropdown-002' class='tbox select form-control' tabindex='5'><option value='0' selected='selected'>Option 0</option><option value='1'>Option 1</option><option value='2'>Option 2</option></select>",
|
||||||
|
|
||||||
|
|
||||||
|
'textarea_001' => "<textarea name='textarea_001' rows='5' cols='40' id='textarea-001' class='form-control input-xlarge' tabindex='6'>the quick brown fox jumps over the lazy dog</textarea>",
|
||||||
|
|
||||||
|
'layout_001' => "<select name='layout_001' id='news_view' class='tbox select form-control' tabindex='7'><option value='default' selected='selected'>Default</option><option value='videos'>Videos (experimental)</option></select>",
|
||||||
|
'layout_002' => "<select name='layout_002' id='news_view' class='tbox select form-control' tabindex='8'><option value='default' selected='selected'>Default</option><option value='videos'>Videos (experimental)</option></select>"
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user