} else {
$checked = $this->isRadioButtonChecked($this->value($this->object()), $tagValue);
}
- if ($checked) {
- $options['checked'] = 'checked';
- }
+ $options['checked'] = (boolean)$checked;
$prettyTagValue = strval($tagValue);
$prettyTagValue = preg_replace('/\s/', '_', $prettyTagValue);
} else {
$checked = $this->isCheckBoxChecked($this->value($this->object()), $checkedValue);
}
- if ($checked) {
- $options['checked'] = 'checked';
- }
+ $options['checked'] = (boolean)$checked;
$options = $this->addDefaultNameAndId($options);
// hidden must output first in PHP to not overwrite checkbox value
public function checkBoxTag($name, $value = '1', $checked = false, $options = array())
{
- $htmlOptions = array_merge(array('type' => 'checkbox',
- 'name' => $name,
- 'id' => $name,
- 'value' => $value), $options);
- if ($checked) {
- $htmlOptions['checked'] = 'checked';
- }
+ $htmlOptions = array_merge(array('type' => 'checkbox',
+ 'name' => $name,
+ 'id' => $name,
+ 'value' => $value,
+ 'checked' => $checked), $options);
return $this->tag('input', $htmlOptions);
}
$htmlOptions = array_merge(array('type' => 'radio',
'name' => $name,
'id' => "{$name}_{$prettyTagValue}",
- 'value' => $value), $options);
- if ($checked) {
- $htmlOptions['checked'] = 'checked';
- }
+ 'value' => $value,
+ 'checked' => $checked), $options);
return $this->tag('input', $htmlOptions);
}
/**
* Use these methods to generate HTML tags programmatically.
- * By default, they output XHTML compliant tags.
+ * By default, they output HTML 4.01 Strict compliant tags.
*
* @author Mike Naberezny <mike@maintainable.com>
* @author Derek DeVries <derek@maintainable.com>
class Horde_View_Helper_Tag extends Horde_View_Helper_Base
{
/**
- * HTML attributes that get converted from boolean to the attribute name:
- * array('disabled' => true) becomes array('disabled' => 'disabled')
+ * Boolean HTML attributes:
+ * array('disabled' => true) is displayed as just "disabled".
*
* @var array
*/
- private $_booleanAttributes = array('disabled', 'readonly', 'multiple');
+ private $_booleanAttributes = array('checked', 'disabled', 'multiple', 'readonly', 'selected');
/**
- * Returns an empty HTML tag of type $name which by default is XHTML
- * compliant. Setting $open to true will create an open tag compatible
- * with HTML 4.0 and below. Add HTML attributes by passing an attributes
- * hash to $options. For attributes with no value (like disabled and
- * readonly), give it a value of TRUE in the $options array.
+ * Returns an empty HTML tag of type $name. Add HTML attributes by passing
+ * an attributes hash to $options. For attributes with no value (like
+ * disabled and readonly), give it a value of TRUE in the $options array.
*
* $this->tag("br")
- * # => <br />
- * $this->tag("br", null, true)
- * # => <br>
+ * # => <br>
* $this->tag("input", array('type' => 'text', 'disabled' => true))
- * # => <input type="text" disabled="disabled" />
+ * # => <input type="text" disabled="disabled">
*
* @param string $name Tag name
* @param string $options Tag attributes
- * @param boolean $open Leave tag open for HTML 4.0 and below?
- * @param string Generated HTML tag
+ * @return string Generated HTML tag
*/
- public function tag($name, $options = null, $open = false)
+ public function tag($name, $options = null)
{
return "<$name"
- . ($options ? $this->tagOptions($options) : '')
- . ($open ? '>' : ' />');
+ . ($options ? $this->tagOptions($options) : '')
+ . '>';
}
/**
*/
public function tagOptions($options)
{
- foreach ($options as $k => &$v) {
+ foreach ($options as $k => $v) {
if ($v === null || $v === false) {
unset($options[$k]);
- } else {
- if (in_array($k, $this->_booleanAttributes)) {
- $v = $k;
- }
}
}
if (! empty($options)) {
foreach ($options as $k => &$v) {
- $v = $k . '="' . $this->escapeOnce($v) . '"';
+ if (in_array($k, $this->_booleanAttributes)) {
+ $v = $k;
+ } else {
+ $v = $k . '="' . $this->escapeOnce($v) . '"';
+ }
}
sort($options);
return ' ' . implode(' ', $options);
public function testFormTagWithMethod()
{
$actual = $this->view->formTag(array(), array('method' => 'put'));
- $expected = '<form action="http://www.example.com" method="post"><div style="margin:0;padding:0"><input name="_method" type="hidden" value="put" /></div>';
+ $expected = '<form action="http://www.example.com" method="post"><div style="margin:0;padding:0"><input name="_method" type="hidden" value="put"></div>';
$this->assertEquals($expected, $actual);
}
public function testCheckBoxTag()
{
$actual = $this->view->checkBoxTag('admin');
- $expected = '<input id="admin" name="admin" type="checkbox" value="1" />';
- $this->assertDomEquals($expected, $actual);
+ $expected = '<input id="admin" name="admin" type="checkbox" value="1">';
+ $this->assertHtmlDomEquals($expected, $actual);
}
public function testHiddenFieldTag()
{
$actual = $this->view->hiddenFieldTag('id', 3);
- $expected = '<input id="id" name="id" type="hidden" value="3" />';
- $this->assertDomEquals($expected, $actual);
+ $expected = '<input id="id" name="id" type="hidden" value="3">';
+ $this->assertHtmlDomEquals($expected, $actual);
}
public function testFileFieldTag()
{
$actual = $this->view->fileFieldTag('id');
- $expected = '<input id="id" name="id" type="file" />';
- $this->assertDomEquals($expected, $actual);
+ $expected = '<input id="id" name="id" type="file">';
+ $this->assertHtmlDomEquals($expected, $actual);
}
public function testPasswordFieldTag()
{
$actual = $this->view->passwordFieldTag();
- $expected = '<input id="password" name="password" type="password" />';
- $this->assertDomEquals($expected, $actual);
+ $expected = '<input id="password" name="password" type="password">';
+ $this->assertHtmlDomEquals($expected, $actual);
}
public function testRadioButtonTag()
{
$actual = $this->view->radioButtonTag('people', 'david');
- $expected = '<input id="people_david" name="people" type="radio" value="david" />';
- $this->assertDomEquals($expected, $actual);
+ $expected = '<input id="people_david" name="people" type="radio" value="david">';
+ $this->assertHtmlDomEquals($expected, $actual);
$actual = $this->view->radioButtonTag('num_people', 5);
- $expected = '<input id="num_people_5" name="num_people" type="radio" value="5" />';
- $this->assertDomEquals($expected, $actual);
+ $expected = '<input id="num_people_5" name="num_people" type="radio" value="5">';
+ $this->assertHtmlDomEquals($expected, $actual);
$actual = $this->view->radioButtonTag('gender', 'm')
. $this->view->radioButtonTag('gender', 'f');
- $expected = '<input id="gender_m" name="gender" type="radio" value="m" />'
- . '<input id="gender_f" name="gender" type="radio" value="f" />';
- $this->assertEquals($expected, $actual); // @todo assertDomEquals
+ $expected = '<input id="gender_m" name="gender" type="radio" value="m">'
+ . '<input id="gender_f" name="gender" type="radio" value="f">';
+ $this->assertEquals($expected, $actual); // @todo assertHtmlDomEquals
$actual = $this->view->radioButtonTag('opinion', '-1')
. $this->view->radioButtonTag('opinion', '1');
- $expected = '<input id="opinion_-1" name="opinion" type="radio" value="-1" />'
- . '<input id="opinion_1" name="opinion" type="radio" value="1" />';
- $this->assertEquals($expected, $actual); // @todo assertDomEquals
+ $expected = '<input id="opinion_-1" name="opinion" type="radio" value="-1">'
+ . '<input id="opinion_1" name="opinion" type="radio" value="1">';
+ $this->assertEquals($expected, $actual); // @todo assertHtmlDomEquals
}
public function testSelectTag()
{
$actual = $this->view->selectTag('people', '<option>david</option>');
$expected = '<select id="people" name="people"><option>david</option></select>';
- $this->assertDomEquals($expected, $actual);
+ $this->assertHtmlDomEquals($expected, $actual);
}
public function testTextAreaTagSizeString()
{
$actual = $this->view->textAreaTag('body', 'hello world', array('size' => '20x40'));
$expected = '<textarea cols="20" id="body" name="body" rows="40">hello world</textarea>';
- $this->assertDomEquals($expected, $actual);
+ $this->assertHtmlDomEquals($expected, $actual);
}
public function testTextAreaTagShouldDisregardSizeIfGivenAsAnInteger()
{
$actual = $this->view->textAreaTag('body', 'hello world', array('size' => 20));
$expected = '<textarea id="body" name="body">hello world</textarea>';
- $this->assertDomEquals($expected, $actual);
+ $this->assertHtmlDomEquals($expected, $actual);
}
public function testTextFieldTag()
{
$actual = $this->view->textFieldTag('title', 'Hello!');
- $expected = '<input id="title" name="title" type="text" value="Hello!" />';
- $this->assertDomEquals($expected, $actual);
+ $expected = '<input id="title" name="title" type="text" value="Hello!">';
+ $this->assertHtmlDomEquals($expected, $actual);
}
public function testTextFieldTagClassString()
{
$actual = $this->view->textFieldTag('title', 'Hello!', array('class' => 'admin'));
- $expected = '<input class="admin" id="title" name="title" type="text" value="Hello!" />';
- $this->assertDomEquals($expected, $actual);
+ $expected = '<input class="admin" id="title" name="title" type="text" value="Hello!">';
+ $this->assertHtmlDomEquals($expected, $actual);
}
public function testBooleanOptions()
{
- $this->assertDomEquals('<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1" />',
+ $this->assertHtmlDomEquals('<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1">',
$this->view->checkBoxTag("admin", 1, true, array('disabled' => true, 'readonly' => "yes")));
- $this->assertDomEquals('<input checked="checked" id="admin" name="admin" type="checkbox" value="1" />',
+ $this->assertHtmlDomEquals('<input checked="checked" id="admin" name="admin" type="checkbox" value="1">',
$this->view->checkBoxTag('admin', 1, true, array('disabled' => false, 'readonly' => null)));
- $this->assertDomEquals('<select id="people" multiple="multiple" name="people"><option>david</option></select>',
+ $this->assertHtmlDomEquals('<select id="people" multiple="multiple" name="people"><option>david</option></select>',
$this->view->selectTag('people', '<option>david</option>', array('multiple' => true)));
- $this->assertDomEquals('<select id="people" name="people"><option>david</option></select>',
+ $this->assertHtmlDomEquals('<select id="people" name="people"><option>david</option></select>',
$this->view->selectTag('people', '<option>david</option>', array('multiple' => null)));
}
public function testSubmitTag()
{
- $expected = '<input name="commit" onclick="this.setAttribute(\'originalValue\', this.value);this.disabled=true;this.value=\'Saving...\';alert(\'hello!\');result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute(\'originalValue\'); this.disabled = false };return result" type="submit" value="Save" />';
+ $expected = '<input name="commit" onclick="this.setAttribute(\'originalValue\', this.value);this.disabled=true;this.value=\'Saving...\';alert(\'hello!\');result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute(\'originalValue\'); this.disabled = false };return result" type="submit" value="Save">';
$actual = $this->view->submitTag('Save', array('disableWith' => 'Saving...', 'onclick' => "alert('hello!')"));
- $this->assertDomEquals($expected, $actual);
+ $this->assertHtmlDomEquals($expected, $actual);
}
}
public function testTextField()
{
$this->assertEquals(
- '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />',
+ '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World">',
$this->view->textField('post', 'title'));
$this->assertEquals(
- '<input id="post_title" name="post[title]" size="30" type="password" value="Hello World" />',
+ '<input id="post_title" name="post[title]" size="30" type="password" value="Hello World">',
$this->view->passwordField('post', 'title'));
$this->assertEquals(
- '<input id="person_name" name="person[name]" size="30" type="password" />',
+ '<input id="person_name" name="person[name]" size="30" type="password">',
$this->view->passwordField("person", "name"));
}
{
$this->post->title = '<b>Hello World</b>';
$this->assertEquals(
- '<input id="post_title" name="post[title]" size="30" type="text" value="<b>Hello World</b>" />',
+ '<input id="post_title" name="post[title]" size="30" type="text" value="<b>Hello World</b>">',
$this->view->textField('post', 'title'));
}
public function testTextFieldWithOptions()
{
- $expected = '<input id="post_title" name="post[title]" size="35" type="text" value="Hello World" />';
+ $expected = '<input id="post_title" name="post[title]" size="35" type="text" value="Hello World">';
$this->assertEquals($expected, $this->view->textField('post', 'title', array('size' => 35)));
}
public function testTextFieldAssumingSize()
{
- $expected = '<input id="post_title" maxlength="35" name="post[title]" size="35" type="text" value="Hello World" />';
+ $expected = '<input id="post_title" maxlength="35" name="post[title]" size="35" type="text" value="Hello World">';
$this->assertEquals($expected, $this->view->textField('post', 'title', array('maxlength' => 35)));
}
public function testTextFieldDoesntChangeParamValues()
{
$objectName = 'post[]';
- $expected = '<input id="post_123_title" name="post[123][title]" size="30" type="text" value="Hello World" />';
+ $expected = '<input id="post_123_title" name="post[123][title]" size="30" type="text" value="Hello World">';
$this->assertEquals($expected, $this->view->textField($objectName, 'title'));
$this->assertEquals($objectName, 'post[]');
}
public function testCheckBox()
{
$this->assertEquals(
- '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
+ '<input name="post[secret]" type="hidden" value="0"><input checked id="post_secret" name="post[secret]" type="checkbox" value="1">',
$this->view->checkBox('post', 'secret'));
$this->post->secret = 0;
$this->assertEquals(
- '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />',
+ '<input name="post[secret]" type="hidden" value="0"><input id="post_secret" name="post[secret]" type="checkbox" value="1">',
$this->view->checkBox('post', 'secret'));
$this->assertEquals(
- '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
- $this->view->checkBox('post', 'secret', array('checked' => 'checked')));
+ '<input name="post[secret]" type="hidden" value="0"><input checked id="post_secret" name="post[secret]" type="checkbox" value="1">',
+ $this->view->checkBox('post', 'secret', array('checked' => true)));
$this->post->secret = true;
$this->assertEquals(
- '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
+ '<input name="post[secret]" type="hidden" value="0"><input checked id="post_secret" name="post[secret]" type="checkbox" value="1">',
$this->view->checkBox('post', 'secret'));
}
$this->post->secret = 'on';
$this->assertEquals(
- '<input name="post[secret]" type="hidden" value="off" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" />',
+ '<input name="post[secret]" type="hidden" value="off"><input checked id="post_secret" name="post[secret]" type="checkbox" value="on">',
$this->view->checkBox('post', 'secret', array(), 'on', 'off'));
}
public function testRadioButton()
{
$this->assertEquals(
- '<input checked="checked" id="post_title_hello_world" name="post[title]" type="radio" value="Hello World" />',
+ '<input checked id="post_title_hello_world" name="post[title]" type="radio" value="Hello World">',
$this->view->radioButton('post', 'title', 'Hello World'));
$this->assertEquals(
- '<input id="post_title_goodbye_world" name="post[title]" type="radio" value="Goodbye World" />',
+ '<input id="post_title_goodbye_world" name="post[title]" type="radio" value="Goodbye World">',
$this->view->radioButton('post', 'title', 'Goodbye World'));
}
public function testRadioButtonIsCheckedWithIntegers()
{
$this->assertEquals(
- '<input checked="checked" id="post_secret_1" name="post[secret]" type="radio" value="1" />',
+ '<input checked id="post_secret_1" name="post[secret]" type="radio" value="1">',
$this->view->radioButton('post', 'secret', '1'));
}
public function testRadioButtonRespectsPassedInId()
{
$this->assertEquals(
- '<input checked="checked" id="foo" name="post[secret]" type="radio" value="1" />',
+ '<input checked id="foo" name="post[secret]" type="radio" value="1">',
$this->view->radioButton('post', 'secret', '1', array('id' => 'foo')));
}
public function testExplicitName()
{
$this->assertEquals(
- '<input id="post_title" name="dont guess" size="30" type="text" value="Hello World" />',
+ '<input id="post_title" name="dont guess" size="30" type="text" value="Hello World">',
$this->view->textField("post", "title", array("name" => "dont guess")));
$this->assertEquals(
$this->view->textArea("post", "body", array("name" => "really!")));
$this->assertEquals(
- '<input name="i mean it" type="hidden" value="0" /><input checked="checked" id="post_secret" name="i mean it" type="checkbox" value="1" />',
+ '<input name="i mean it" type="hidden" value="0"><input checked id="post_secret" name="i mean it" type="checkbox" value="1">',
$this->view->checkBox("post", "secret", array("name" => "i mean it")));
}
public function testExplicitId()
{
$this->assertEquals(
- '<input id="dont guess" name="post[title]" size="30" type="text" value="Hello World" />',
+ '<input id="dont guess" name="post[title]" size="30" type="text" value="Hello World">',
$this->view->textField("post", "title", array("id" => "dont guess")));
$this->assertEquals(
$this->view->textArea("post", "body", array("id" => "really!")));
$this->assertEquals(
- '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="i mean it" name="post[secret]" type="checkbox" value="1" />',
+ '<input name="post[secret]" type="hidden" value="0"><input checked id="i mean it" name="post[secret]" type="checkbox" value="1">',
$this->view->checkBox("post", "secret", array("id" => "i mean it")));
}
$pid = $this->post->id;
$this->assertEquals(
- "<input id=\"post_{$pid}_title\" name=\"post[{$pid}][title]\" size=\"30\" type=\"text\" value=\"Hello World\" />",
+ "<input id=\"post_{$pid}_title\" name=\"post[{$pid}][title]\" size=\"30\" type=\"text\" value=\"Hello World\">",
$this->view->textField("post[]", "title"));
$this->assertEquals(
$this->view->textArea("post[]", "body"));
$this->assertEquals(
- "<input name=\"post[{$pid}][secret]\" type=\"hidden\" value=\"0\" /><input checked=\"checked\" id=\"post_{$pid}_secret\" name=\"post[{$pid}][secret]\" type=\"checkbox\" value=\"1\" />",
+ "<input name=\"post[{$pid}][secret]\" type=\"hidden\" value=\"0\"><input checked id=\"post_{$pid}_secret\" name=\"post[{$pid}][secret]\" type=\"checkbox\" value=\"1\">",
$this->view->checkBox('post[]', 'secret'));
$this->assertEquals(
- "<input checked=\"checked\" id=\"post_{$pid}_title_hello_world\" name=\"post[{$pid}][title]\" type=\"radio\" value=\"Hello World\" />",
+ "<input checked id=\"post_{$pid}_title_hello_world\" name=\"post[{$pid}][title]\" type=\"radio\" value=\"Hello World\">",
$this->view->radioButton('post[]', 'title', 'Hello World'));
$this->assertEquals(
- "<input id=\"post_{$pid}_title_goodbye_world\" name=\"post[{$pid}][title]\" type=\"radio\" value=\"Goodbye World\" />",
+ "<input id=\"post_{$pid}_title_goodbye_world\" name=\"post[{$pid}][title]\" type=\"radio\" value=\"Goodbye World\">",
$this->view->radioButton('post[]', 'title', 'Goodbye World'));
}
$expected =
'<form action="http://www.example.com" id="create-post" method="post">' .
- '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />' .
+ '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World">' .
'<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>' .
- '<input name="post[secret]" type="hidden" value="0" />' .
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />' .
- '<input id="post_submit" name="commit" type="submit" value="Create post" />' .
+ '<input name="post[secret]" type="hidden" value="0">' .
+ '<input checked id="post_secret" name="post[secret]" type="checkbox" value="1">' .
+ '<input id="post_submit" name="commit" type="submit" value="Create post">' .
"</form>";
$this->assertEquals($expected, ob_get_clean());
$expected =
'<form action="http://www.example.com" id="create-post" method="post">' .
- '<div style="margin:0;padding:0"><input name="_method" type="hidden" value="put" /></div>' .
- '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />' .
+ '<div style="margin:0;padding:0"><input name="_method" type="hidden" value="put"></div>' .
+ '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World">' .
'<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>' .
- '<input name="post[secret]" type="hidden" value="0" />' .
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />' .
+ '<input name="post[secret]" type="hidden" value="0">' .
+ '<input checked id="post_secret" name="post[secret]" type="checkbox" value="1">' .
"</form>";
$this->assertEquals($expected, ob_get_clean());
$expected =
'<form action="http://www.example.com" id="create-post" method="post">' .
- '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />' .
+ '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World">' .
'<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>' .
- '<input name="post[secret]" type="hidden" value="0" />' .
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />' .
+ '<input name="post[secret]" type="hidden" value="0">' .
+ '<input checked id="post_secret" name="post[secret]" type="checkbox" value="1">' .
"</form>";
$this->assertEquals($expected, ob_get_clean());
$expected =
'<form action="http://www.example.com" method="post">' .
- '<input id="post_123_title" name="post[123][title]" size="30" type="text" value="Hello World" />' .
+ '<input id="post_123_title" name="post[123][title]" size="30" type="text" value="Hello World">' .
'<textarea cols="40" id="post_123_body" name="post[123][body]" rows="20">Back to the hill and over it again!</textarea>' .
- '<input name="post[123][secret]" type="hidden" value="0" />' .
- '<input checked="checked" id="post_123_secret" name="post[123][secret]" type="checkbox" value="1" />' .
+ '<input name="post[123][secret]" type="hidden" value="0">' .
+ '<input checked id="post_123_secret" name="post[123][secret]" type="checkbox" value="1">' .
'</form>';
$this->assertEquals($expected, ob_get_clean());
$fields->end();
$expected =
- '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />' .
+ '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World">' .
'<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>' .
- '<input name="post[secret]" type="hidden" value="0" />' .
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />';
+ '<input name="post[secret]" type="hidden" value="0">' .
+ '<input checked id="post_secret" name="post[secret]" type="checkbox" value="1">';
$this->assertEquals($expected, ob_get_clean());
}
$expected =
'<form action="http://www.example.com" method="post">' .
- '<input id="post_comment_title" name="post[comment][title]" size="30" type="text" value="Hello World" />' .
+ '<input id="post_comment_title" name="post[comment][title]" size="30" type="text" value="Hello World">' .
'</form>';
$this->assertEquals($expected, ob_get_clean());
$fields->end();
$expected =
- '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />' .
+ '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World">' .
'<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>' .
- '<input name="post[secret]" type="hidden" value="0" />' .
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />';
+ '<input name="post[secret]" type="hidden" value="0">' .
+ '<input checked id="post_secret" name="post[secret]" type="checkbox" value="1">';
$this->assertEquals($expected, ob_get_clean());
}
$fields->end();
$this->assertEquals(
- '<input id="author_post_title" name="author[post][title]" size="30" type="text" value="Hello World" />',
+ '<input id="author_post_title" name="author[post][title]" size="30" type="text" value="Hello World">',
ob_get_clean());
}
$expected =
'<form action="http://www.example.com" id="create-post" method="post">' .
- '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />' .
+ '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World">' .
'<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>' .
- '<input name="parent_post[secret]" type="hidden" value="0" />' .
- '<input checked="checked" id="parent_post_secret" name="parent_post[secret]" type="checkbox" value="1" />' .
+ '<input name="parent_post[secret]" type="hidden" value="0">' .
+ '<input checked id="parent_post_secret" name="parent_post[secret]" type="checkbox" value="1">' .
'</form>';
$this->assertEquals($expected, ob_get_clean());
$expected =
'<form action="http://www.example.com" method="post">' .
- '<input id="post_bar" name="post[bar]" size="30" type="text" />' .
- '<foo /></form>';
+ '<input id="post_bar" name="post[bar]" size="30" type="text">' .
+ '<foo></form>';
$this->assertEquals($expected, ob_get_clean());
}
$expected =
'<form action="http://www.example.com" method="post">' .
- '<input id="post_bar" name="post[bar]" size="30" type="text" />' .
- '<foo /></form>';
+ '<input id="post_bar" name="post[bar]" size="30" type="text">' .
+ '<foo></form>';
$this->assertEquals($expected, ob_get_clean());
} catch (Exception $e) {}
$fields->end();
$this->assertEquals(
- '<input id="post_bar" name="post[bar]" size="30" type="text" /><foo />',
+ '<input id="post_bar" name="post[bar]" size="30" type="text"><foo>',
ob_get_clean());
}
$expected =
'<form action="http://www.example.com" method="post">' .
- '<input id="post_title" name="post[title]" type="hidden" value="Hello World" />' .
+ '<input id="post_title" name="post[title]" type="hidden" value="Hello World">' .
'</form>';
$this->assertEquals($expected, ob_get_clean());
$expected =
'<form action="http://www.example.com" method="post">' .
- '<input id="post_title" name="post[title]" size="30" type="file" />' .
+ '<input id="post_title" name="post[title]" size="30" type="file">' .
'</form>';
$this->assertEquals($expected, ob_get_clean());
{
public function foo()
{
- return '<foo />';
+ return '<foo>';
}
}
public function testTag()
{
- $this->assertEquals('<br />', $this->view->tag('br'));
- $this->assertEquals('<br clear="left" />',
+ $this->assertEquals('<br>', $this->view->tag('br'));
+ $this->assertEquals('<br clear="left">',
$this->view->tag('br', array('clear' => 'left')));
- $this->assertEquals('<br>',
- $this->view->tag('br', null, true));
}
public function testTagOptions()
{
- $this->assertRegExp('/\A<p class="(show|elsewhere)" \/>\z/',
+ $this->assertRegExp('/\A<p class="(show|elsewhere)">\z/',
$this->view->tag('p', array('class' => 'show',
'class' => 'elsewhere')));
}
public function testTagOptionsRejectsNullOption()
{
- $this->assertEquals('<p />',
+ $this->assertEquals('<p>',
$this->view->tag('p', array('ignored' => null)));
}
public function testTagOptionsAcceptsBlankOption()
{
- $this->assertEquals('<p included="" />',
+ $this->assertEquals('<p included="">',
$this->view->tag('p', array('included' => '')));
}
public function testTagOptionsConvertsBooleanOption()
{
- $this->assertEquals('<p disabled="disabled" multiple="multiple" readonly="readonly" />',
+ $this->assertEquals('<p disabled multiple readonly>',
$this->view->tag('p', array('disabled' => true,
'multiple' => true,
'readonly' => true)));
{
$attributes = array('1&2', '1 < 2', '“test“');
foreach ($attributes as $escaped) {
- $this->assertEquals("<a href=\"$escaped\" />",
+ $this->assertEquals("<a href=\"$escaped\">",
$this->view->tag('a', array('href' => $escaped)));
}
}
{
$attributes = array('&1;', 'dfa3;', '& #123;');
foreach ($attributes as $escaped) {
- $this->assertEquals('<a href="' . str_replace('&', '&', $escaped) . '" />',
+ $this->assertEquals('<a href="' . str_replace('&', '&', $escaped) . '">',
$this->view->tag('a', array('href' => $escaped)));
}
}
public function testLinkTagWithImg()
{
- $this->assertEquals("<a href=\"http://www.example.com\"><img src='/favicon.jpg' /></a>",
- $this->view->linkTo("<img src='/favicon.jpg' />", "http://www.example.com"));
+ $this->assertEquals("<a href=\"http://www.example.com\"><img src='/favicon.jpg'></a>",
+ $this->view->linkTo("<img src='/favicon.jpg'>", "http://www.example.com"));
}
public function testLinkToUnless()
public function testMailToWithImg()
{
- $this->assertEquals('<a href="mailto:feedback@example.com"><img src="/feedback.png" /></a>',
- $this->view->mailTo('feedback@example.com', '<img src="/feedback.png" />'));
+ $this->assertEquals('<a href="mailto:feedback@example.com"><img src="/feedback.png"></a>',
+ $this->view->mailTo('feedback@example.com', '<img src="/feedback.png">'));
}
public function testMailToWithHex()