diff --git a/tests/README.md b/tests/README.md index fbb78824..e969384f 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,10 +4,10 @@ For installing the PHPUnit test by composer use the following: "require-dev": { - "smarty/smarty-phpunit": "3.1.12" + "smarty/smarty-phpunit": "3.1.13" } -Replace 3.1.12 with the installed Smarty version number. +Replace 3.1.13 with the installed Smarty version number. Starting with Smarty version 3.1.22 the "require-dev" section will be added to the composer.json file of the Smarty distribution. diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php index 22767e57..7c3fc23e 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php @@ -351,4 +351,63 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); } + + public function testDisabledStrict1() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
" disabled=true strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); + } + public function testDisabledStrict2() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
" disabled=1 strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + } + public function testDisabledStrict3() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="
" disabled="disabled" strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); + } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php index 7c2e0ac4..873ff84e 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php @@ -443,4 +443,58 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); } + + public function testDisabledStrict() + { + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled=1 strict=true}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); + + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled=true strict=true}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); + + $n = "\n"; + $expected = '' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled="disabled" strict=true}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); + } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php index 73cf626d..4160e72b 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php @@ -350,4 +350,58 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); } + + public function testDisabledStrict() + { + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
" disabled=true strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); + + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
" disabled=1 strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); + + $n = "\n"; + $expected = '
' + . $n . '
' + . $n . '
' + . $n . '
'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="
" disabled="disabled" strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch())); + } }