/** * Tests resetInput with displayTo * * @author Nikolaos Dimopoulos <*****@*****.**> * @since 2014-09-05 */ public function testResetInputWithDisplayTo() { $this->specify("resetInput with displayTo returns invalid HTML Strict", function () { Tag::setDoctype(Tag::XHTML10_STRICT); $options = 'x_name'; $expected = '<input type="text" id="x_name" name="x_name" ' . 'value="x_other" />'; Tag::displayTo('x_name', 'x_other'); $actual = Tag::textField($options); Tag::resetInput(); expect($actual)->equals($expected); $expected = '<input type="text" id="x_name" name="x_name" />'; $actual = Tag::textField($options); expect($actual)->equals($expected); }); $this->specify("resetInput with displayTo returns invalid HTML XHTML", function () { Tag::setDoctype(Tag::HTML5); $options = 'x_name'; $expected = '<input type="text" id="x_name" name="x_name" ' . 'value="x_other">'; Tag::displayTo('x_name', 'x_other'); $actual = Tag::textField($options); Tag::resetInput(); expect($actual)->equals($expected); $expected = '<input type="text" id="x_name" name="x_name">'; $actual = Tag::textField($options); expect($actual)->equals($expected); }); }
/** * Tests selectStatic with displayTo and element not present * * @author Nikolaos Dimopoulos <*****@*****.**> * @since 2014-09-05 */ public function testSelectStaticOptGroupWithDisplayToElementNotPresent() { $this->specify("selectStatic with displayTo and element not present returns invalid HTML", function () { Tag::resetInput(); $params = ['x_name', 'name' => 'x_other', 'class' => 'x_class', 'size' => '10']; $options = ["Active" => ['A1' => 'A One', 'A2' => 'A Two'], "B" => "B One"]; $expected = '<select id="x_name" name="x_other" class="x_class" size="10">' . PHP_EOL . chr(9) . '<optgroup label="Active">' . PHP_EOL . chr(9) . '<option value="A1">A One</option>' . PHP_EOL . chr(9) . '<option value="A2">A Two</option>' . PHP_EOL . chr(9) . '</optgroup>' . PHP_EOL . chr(9) . '<option value="B">B One</option>' . PHP_EOL . '</select>'; Tag::displayTo('x_name', 'I'); $actual = Tag::selectStatic($params, $options); Tag::resetInput(); expect($actual)->equals($expected); }); }