First pass at making form and tag helpers HTML 4.01 Strict
authorChuck Hagenbuch <chuck@horde.org>
Sun, 20 Dec 2009 08:21:47 +0000 (03:21 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 20 Dec 2009 08:21:47 +0000 (03:21 -0500)
framework/View/lib/Horde/View/Helper/Form/InstanceTag/Form.php
framework/View/lib/Horde/View/Helper/FormTag.php
framework/View/lib/Horde/View/Helper/Tag.php
framework/View/test/Horde/View/Helper/FormTagTest.php
framework/View/test/Horde/View/Helper/FormTest.php
framework/View/test/Horde/View/Helper/TagTest.php
framework/View/test/Horde/View/Helper/UrlTest.php

index 6fbb290..b6d5f4f 100644 (file)
@@ -62,9 +62,7 @@ class Horde_View_Helper_Form_InstanceTag_Form extends Horde_View_Helper_Form_Ins
         } 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);
@@ -116,9 +114,7 @@ class Horde_View_Helper_Form_InstanceTag_Form extends Horde_View_Helper_Form_Ins
         } 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
index 18e2a91..ba01e4f 100644 (file)
@@ -80,13 +80,11 @@ class Horde_View_Helper_FormTag extends Horde_View_Helper_Base
 
     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);
     }
@@ -99,10 +97,8 @@ class Horde_View_Helper_FormTag extends Horde_View_Helper_Base
         $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);
     }
index 34de238..d70f0b3 100644 (file)
@@ -14,7 +14,7 @@
 
 /**
  * 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) : '')
+            . '>';
     }
 
     /**
@@ -139,19 +134,19 @@ class Horde_View_Helper_Tag extends Horde_View_Helper_Base
      */
     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);
index 3398abd..06db8f0 100644 (file)
@@ -56,116 +56,116 @@ class Horde_View_Helper_FormTagTest extends Horde_Test_Functional
     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);
     }
 
 }
index 7e5ccdd..47cea78 100644 (file)
@@ -48,15 +48,15 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
     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"));
     }
 
@@ -64,26 +64,26 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
     {
         $this->post->title = '<b>Hello World</b>';
         $this->assertEquals(
-            '<input id="post_title" name="post[title]" size="30" type="text" value="&lt;b&gt;Hello World&lt;/b&gt;" />',
+            '<input id="post_title" name="post[title]" size="30" type="text" value="&lt;b&gt;Hello World&lt;/b&gt;">',
             $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[]');
     }
@@ -91,23 +91,23 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
     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'));
     }
 
@@ -116,32 +116,32 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
         $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')));
     }
 
@@ -177,7 +177,7 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
     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(
@@ -185,14 +185,14 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
             $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(
@@ -200,7 +200,7 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
             $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")));
     }
 
@@ -209,7 +209,7 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
         $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(
@@ -217,15 +217,15 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
             $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'));
     }
 
@@ -241,11 +241,11 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
 
         $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());
@@ -263,11 +263,11 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
 
         $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());
@@ -284,10 +284,10 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
 
         $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());
@@ -304,10 +304,10 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
 
         $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());
@@ -323,10 +323,10 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
         $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());
     }
@@ -342,7 +342,7 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
 
         $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());
@@ -358,10 +358,10 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
         $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());
     }
@@ -374,7 +374,7 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
         $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());
     }
 
@@ -398,10 +398,10 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
 
         $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());
@@ -417,8 +417,8 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
 
         $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());
     }
@@ -437,8 +437,8 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
 
             $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) {}
@@ -458,7 +458,7 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
         $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());
     }
 
@@ -483,7 +483,7 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
 
         $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());
@@ -498,7 +498,7 @@ class Horde_View_Helper_FormTest extends Horde_Test_Case
 
         $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());
@@ -521,6 +521,6 @@ class Horde_View_Helper_FormTest_BuilderMock extends Horde_View_Helper_Form_Buil
 {
     public function foo()
     {
-        return '<foo />';
+        return '<foo>';
     }
 }
index 098f44e..e2fe0ff 100644 (file)
@@ -32,35 +32,33 @@ class Horde_View_Helper_TagTest extends Horde_Test_Case
 
     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)));
@@ -86,7 +84,7 @@ class Horde_View_Helper_TagTest extends Horde_Test_Case
     {
         $attributes = array('1&amp;2', '1 &lt; 2', '&#8220;test&#8220;');
         foreach ($attributes as $escaped) {
-            $this->assertEquals("<a href=\"$escaped\" />",
+            $this->assertEquals("<a href=\"$escaped\">",
                                 $this->view->tag('a', array('href' => $escaped)));
         }
     }
@@ -95,7 +93,7 @@ class Horde_View_Helper_TagTest extends Horde_Test_Case
     {
         $attributes = array('&1;', '&#1dfa3;', '& #123;');
         foreach ($attributes as $escaped) {
-            $this->assertEquals('<a href="' . str_replace('&', '&amp;', $escaped) . '" />',
+            $this->assertEquals('<a href="' . str_replace('&', '&amp;', $escaped) . '">',
                                 $this->view->tag('a', array('href' => $escaped)));
         }
     }
index b1d9489..3d2ff0a 100644 (file)
@@ -53,8 +53,8 @@ class Horde_View_Helper_UrlTest extends Horde_Test_Case
 
     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()
@@ -102,8 +102,8 @@ class Horde_View_Helper_UrlTest extends Horde_Test_Case
 
     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()