Example #1
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);
 }
Example #2
0
 /**
  * Tests titleSeparator prepend
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2012-09-05
  */
 public function testSetTitleSeparatorPrepend()
 {
     $this->specify("titleSeparator prepend returns incorrect result", function () {
         PhTTag::resetInput();
         $value = 'This is my title';
         $addon = 'PhalconPHP';
         PhTTag::setTitle($value);
         PhTTag::setTitleSeparator('-');
         PhTTag::prependTitle($addon);
         $expected = "<title>{$addon}-{$value}</title>" . PHP_EOL;
         $actual = PhTTag::getTitle();
         expect($actual)->equals($expected);
     });
 }
Example #3
0
 /**
  * Tests tagHtmlClose with EOL
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2014-09-05
  */
 public function testTagHtmlCloseEol()
 {
     $this->specify("tagHtmlClose with EOL returns invalid HTML Strict", function () {
         PhTTag::resetInput();
         $name = 'canvas';
         $expected = '</canvas>' . PHP_EOL;
         PhTTag::setDocType(PhTTag::XHTML10_STRICT);
         $actual = PhTTag::tagHtmlClose($name, true);
         expect($actual)->equals($expected);
     });
     $this->specify("tagHtmlClose with EOL returns invalid HTML XHTML", function () {
         PhTTag::resetInput();
         $name = 'canvas';
         $expected = '</canvas>' . PHP_EOL;
         PhTTag::setDocType(PhTTag::HTML5);
         $actual = PhTTag::tagHtmlClose($name, true);
         expect($actual)->equals($expected);
     });
 }
Example #4
0
 /**
  * Tests textArea with displayTo and newline in value
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2014-10-03
  */
 public function testTextAreaWithDisplayToAndNewlineInValue()
 {
     $this->specify("textArea with displayTo and newline in value", function () {
         $options = 'x_name';
         $value = "\r\nx_content";
         $expected = '<textarea id="x_name" name="x_name">' . $value . '</textarea>';
         PhTTag::setDefault('x_name', $value);
         $actual = PhTTag::textArea($options);
         PhTTag::setDefault('x_name', '');
         expect($actual)->equals($expected);
     });
 }
Example #5
0
 /**
  * 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);
     });
 }
Example #6
0
 /**
  * Tests linkTo with complex remote URL
  *
  * @issue  1679
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @author Dreamszhu <*****@*****.**>
  * @since  2014-09-29
  */
 public function testLinkToWithComplexRemoteUrl()
 {
     $this->specify("linkTo with complex remote URL string parameter returns invalid HTML", function () {
         PhTTag::resetInput();
         $url = "http://phalconphp.com/en/";
         $name = 'x_name';
         $actual = PhTTag::linkTo($url, $name, false);
         $expected = '<a href="http://phalconphp.com/en/">x_name</a>';
         expect($actual)->equals($expected);
     });
     $this->specify("linkTo with complex remote URL array parameter returns invalid HTML", function () {
         PhTTag::resetInput();
         $options = ["http://phalconphp.com/en/", 'x_name', false];
         $actual = PhTTag::linkTo($options);
         $expected = '<a href="http://phalconphp.com/en/">x_name</a>';
         expect($actual)->equals($expected);
     });
     $this->specify("linkTo with complex remote URL array named parameter returns invalid HTML", function () {
         PhTTag::resetInput();
         $options = ["http://phalconphp.com/en/", 'text' => 'x_name', 'local' => false];
         $actual = PhTTag::linkTo($options);
         $expected = '<a href="http://phalconphp.com/en/">x_name</a>';
         expect($actual)->equals($expected);
     });
     $this->specify("linkTo with mailto URL string parameter returns invalid HTML", function () {
         PhTTag::resetInput();
         $url = "mailto:someone@phalconphp.com";
         $name = '*****@*****.**';
         $actual = PhTTag::linkTo($url, $name, false);
         $expected = '<a href="mailto:someone@phalconphp.com">someone@phalconphp.com</a>';
         expect($actual)->equals($expected);
     });
 }
Example #7
0
 /**
  * Runs a doctype test, one for each doctype
  *
  * @param integer $doctype
  */
 protected function runDoctypeTest($doctype)
 {
     PhTTag::resetInput();
     PhTTag::setDocType($doctype);
     $expected = $this->docTypeToString($doctype);
     $actual = PhTTag::getDocType();
     PhTTag::setDocType(PhTTag::HTML5);
     expect($actual)->equals($expected);
 }
Example #8
0
 /**
  * Tests endForm with an array as parameters
  *
  * @issue  57
  * @author Nikos Dimopoulos <*****@*****.**>
  * @since  2012-11-29
  */
 public function testEndForm()
 {
     $expected = '</form>';
     $actual = PhTTag::endForm();
     $this->assertEquals($expected, $actual, sprintf($this->message, 'endForm'));
 }
Example #9
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);
     });
 }
 /**
  * Tests javascriptInclude with array parameter for a remote link
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2014-09-29
  */
 public function testJavascriptIncludeWithArrayRemote()
 {
     $this->specify("iavascriptInclude with array second parameter remote link returns invalid HTML", function () {
         PhTTag::resetInput();
         $options = ['http://my.local.com/js/phalcon.js'];
         $expected = '<script type="text/javascript" src="http://my.local.com/js/phalcon.js"></script>' . PHP_EOL;
         $actual = PhTTag::javascriptInclude($options, false);
         expect($actual)->equals($expected);
     });
 }
Example #11
0
 /**
  * Tests image with array parameter and remote link
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2014-09-05
  */
 public function testImageArrayParameterRemoteLink()
 {
     $this->specify("image with array parameter and remote link returns invalid HTML Strict", function () {
         $options = ['http://phalconphp.com/img/hello.gif', 'alt' => 'Hello'];
         $expected = '<img src="http://phalconphp.com/img/hello.gif" ' . 'alt="Hello" />';
         PhTTag::setDocType(PhTTag::XHTML10_STRICT);
         $actual = PhTTag::image($options, false);
         expect($actual)->equals($expected);
     });
     $this->specify("image with array parameter and local link returns invalid HTML XHTML", function () {
         $options = ['http://phalconphp.com/img/hello.gif', 'alt' => 'Hello'];
         $expected = '<img src="http://phalconphp.com/img/hello.gif" ' . 'alt="Hello">';
         PhTTag::setDocType(PhTTag::HTML5);
         $actual = PhTTag::image($options, false);
         expect($actual)->equals($expected);
     });
 }
Example #12
0
 /**
  * Tests friendlyTitle with string as a parameter with replace as boolean
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2014-09-11
  */
 public function testFriendlyTitleStringParameterReplaceBoolean()
 {
     $this->specify("friendlyTitle with string parameter with replace array returns incorrect text", function () {
         PhTTag::resetInput();
         $options = 'This is a Test';
         $expected = 't_s_s_a_test';
         $actual = PhTTag::friendlyTitle($options, '_', true, true);
         expect($actual)->equals($expected);
     }, ['throws' => new PhTagException()]);
 }
Example #13
0
 /**
  * Tests stylesheetLink overriding the rel link local
  *
  * @issue  2142
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @author Dreamszhu <*****@*****.**>
  * @since  2014-09-12
  */
 public function testStylesheetLinkOverrideRelLink()
 {
     $this->specify("stylesheetLink overriding rel local returns invalid HTML Strict", function () {
         PhTTag::resetInput();
         $options = ['css/phalcon.css', 'rel' => 'stylesheet/less'];
         $expected = '<link rel="stylesheet/less" type="text/css" ' . 'href="/css/phalcon.css" />' . PHP_EOL;
         PhTTag::setDocType(PhTTag::XHTML10_STRICT);
         $actual = PhTTag::stylesheetLink($options);
         expect($actual)->equals($expected);
     });
     $this->specify("stylesheetLink overriding rel local returns invalid HTML Strict", function () {
         PhTTag::resetInput();
         $options = ['css/phalcon.css', 'rel' => 'stylesheet/less'];
         $expected = '<link rel="stylesheet/less" type="text/css" ' . 'href="/css/phalcon.css">' . PHP_EOL;
         PhTTag::setDocType(PhTTag::HTML5);
         $actual = PhTTag::stylesheetLink($options);
         expect($actual)->equals($expected);
     });
 }