diff --git a/classes/HTML.php b/classes/HTML.php index 35450b1..b7bf281 100644 --- a/classes/HTML.php +++ b/classes/HTML.php @@ -132,19 +132,13 @@ class HTML extends Object $html .= ' ' . $attribute . '="' . str_replace('"', '\"', $value) . '"'; } } - else - { - throw new Exception('Attributes must be an array.'); - } } - if ($contents || !in_array($element, $this->self_closing)) + $html .= '>'; + + if (!in_array($element, $this->self_closing)) { - $html .= '>' . $contents . '' . $element . '>'; - } - else - { - $html .= ' />'; + $html .= $contents . '' . $element . '>'; } return $html; diff --git a/tests/TODO b/tests/TODO index 24c89ed..8ac6a3b 100644 --- a/tests/TODO +++ b/tests/TODO @@ -1,7 +1,6 @@ Cache Config Database -HTML Model Module Profiler diff --git a/tests/classes/HTMLTest.php b/tests/classes/HTMLTest.php new file mode 100644 index 0000000..d5afb4e --- /dev/null +++ b/tests/classes/HTMLTest.php @@ -0,0 +1,99 @@ +html = HTML::getInstance(); + } + + public function testGetInstance() + { + $this->assertInstanceOf('HTML', $this->html); + } + + public function testInput() + { + $this->assertEquals('', $this->html->input()); + } + + public function testInputDateTimeLocal() + { + $this->assertEquals('', $this->html->inputDateTimeLocal()); + } + + public function testInputEmail() + { + $this->assertEquals('', $this->html->inputEmail()); + } + + public function testInputWithAttributes() + { + $this->assertEquals( + '', + $this->html->input([ + 'id' => 'id', + 'class' => 'class', + 'value' => 'value', + ]) + ); + } + + public function testInputPasswordWithLabel() + { + $this->assertEquals( + '', + $this->html->inputPassword([ + 'name' => 'password', + 'label' => 'Enter Password', + ]) + ); + + } + + public function testNestedElements() + { + $this->assertEquals( + '
Nested!
Nested!