Beispiel #1
0
 /**
  * Tests resetInput with displayTo
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2014-09-05
  */
 public function testResetInputWithDisplayTo()
 {
     $this->specify("resetInput with displayTo returns invalid HTML Strict", function () {
         PhTTag::setDoctype(PhTTag::XHTML10_STRICT);
         $options = 'x_name';
         $expected = '<input type="text" id="x_name" name="x_name" ' . 'value="x_other" />';
         PhTTag::displayTo('x_name', 'x_other');
         $actual = PhTTag::textField($options);
         PhTTag::resetInput();
         expect($actual)->equals($expected);
         $expected = '<input type="text" id="x_name" name="x_name" />';
         $actual = PhTTag::textField($options);
         expect($actual)->equals($expected);
     });
     $this->specify("resetInput with displayTo returns invalid HTML XHTML", function () {
         PhTTag::setDoctype(PhTTag::HTML5);
         $options = 'x_name';
         $expected = '<input type="text" id="x_name" name="x_name" ' . 'value="x_other">';
         PhTTag::displayTo('x_name', 'x_other');
         $actual = PhTTag::textField($options);
         PhTTag::resetInput();
         expect($actual)->equals($expected);
         $expected = '<input type="text" id="x_name" name="x_name">';
         $actual = PhTTag::textField($options);
         expect($actual)->equals($expected);
     });
 }
Beispiel #2
0
 /**
  * Runs the test for a Tag:: element with parameters
  *
  * @param string    $function
  * @param mixed     $options
  * @param string    $expected
  * @param boolean   $xhtml
  * @param string    $set
  */
 public function fieldParameter($function, $options, $expected, $xhtml, $set = '')
 {
     PhTTag::resetInput();
     if ($xhtml) {
         PhTTag::setDocType(PhTTag::XHTML10_STRICT);
     } else {
         PhTTag::setDocType(PhTTag::HTML5);
     }
     $expected .= $xhtml ? ' />' : '>';
     if ($set) {
         PhTTag::displayTo('x_name', 'x_value');
     }
     $actual = PhTTag::$function($options);
     if ($set) {
         PhTTag::$set('x_name', '');
     }
     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 () {
         PhTTag::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>';
         PhTTag::displayTo('x_name', 'I');
         $actual = PhTTag::selectStatic($params, $options);
         PhTTag::resetInput();
         expect($actual)->equals($expected);
     });
 }