/**
  * Tests setDefault
  *
  * @issue  2402
  * @author Dmitry Patsura <*****@*****.**>
  * @since  2014-05-10
  */
 public function testDisplayValues()
 {
     $this->specify("setDefault does not assigns default values to generated tags by helpers", function () {
         Tag::setDefault('property1', 'testVal1');
         Tag::setDefault('property2', 'testVal2');
         Tag::setDefault('property3', 'testVal3');
         expect(Tag::hasValue('property1'))->true();
         expect(Tag::hasValue('property2'))->true();
         expect(Tag::hasValue('property3'))->true();
         expect(Tag::hasValue('property4'))->false();
         expect(Tag::getValue('property1'))->equals('testVal1');
         expect(Tag::getValue('property2'))->equals('testVal2');
         expect(Tag::getValue('property3'))->equals('testVal3');
     });
 }
 /**
  * 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 () {
         Tag::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 = Tag::javascriptInclude($options, false);
         expect($actual)->equals($expected);
     });
 }
 /**
  * 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 () {
         Tag::resetInput();
         $options = ['css/phalcon.css', 'rel' => 'stylesheet/less'];
         $expected = '<link rel="stylesheet/less" type="text/css" ' . 'href="/css/phalcon.css" />' . PHP_EOL;
         Tag::setDocType(Tag::XHTML10_STRICT);
         $actual = Tag::stylesheetLink($options);
         expect($actual)->equals($expected);
     });
     $this->specify("stylesheetLink overriding rel local returns invalid HTML Strict", function () {
         Tag::resetInput();
         $options = ['css/phalcon.css', 'rel' => 'stylesheet/less'];
         $expected = '<link rel="stylesheet/less" type="text/css" ' . 'href="/css/phalcon.css">' . PHP_EOL;
         Tag::setDocType(Tag::HTML5);
         $actual = Tag::stylesheetLink($options);
         expect($actual)->equals($expected);
     });
 }
 /**
  * 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 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 () {
         Tag::resetInput();
         $options = 'This is a Test';
         $expected = 't_s_s_a_test';
         $actual = Tag::friendlyTitle($options, '_', true, true);
         expect($actual)->equals($expected);
     }, ['throws' => ['Phalcon\\Tag\\Exception']]);
 }
Beispiel #6
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 () {
         Tag::resetInput();
         $name = 'canvas';
         $expected = '</canvas>' . PHP_EOL;
         Tag::setDocType(Tag::XHTML10_STRICT);
         $actual = Tag::tagHtmlClose($name, true);
         expect($actual)->equals($expected);
     });
     $this->specify("tagHtmlClose with EOL returns invalid HTML XHTML", function () {
         Tag::resetInput();
         $name = 'canvas';
         $expected = '</canvas>' . PHP_EOL;
         Tag::setDocType(Tag::HTML5);
         $actual = Tag::tagHtmlClose($name, true);
         expect($actual)->equals($expected);
     });
 }
Beispiel #7
0
 /**
  * Tests titleSeparator prepend
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2012-09-05
  */
 public function testSetTitleSeparatorPrepend()
 {
     $this->specify("titleSeparator prepend returns incorrect result", function () {
         Tag::resetInput();
         Tag::setTitle('This is my title');
         Tag::setTitleSeparator('-');
         Tag::prependTitle('PhalconPHP');
         expect(Tag::getTitle())->equals("<title>PhalconPHP-This is my title</title>" . PHP_EOL);
     });
 }
Beispiel #8
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" />';
         Tag::setDocType(Tag::XHTML10_STRICT);
         $actual = Tag::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">';
         Tag::setDocType(Tag::HTML5);
         $actual = Tag::image($options, false);
         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);
     });
 }
Beispiel #10
0
 /**
  * Runs a doctype test, one for each doctype
  *
  * @param integer $doctype
  */
 protected function runDoctypeTest($doctype)
 {
     Tag::resetInput();
     Tag::setDocType($doctype);
     $expected = $this->docTypeToString($doctype);
     $actual = Tag::getDocType();
     Tag::setDocType(Tag::HTML5);
     expect($actual)->equals($expected);
 }
Beispiel #11
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>';
         Tag::setDefault('x_name', $value);
         $actual = Tag::textArea($options);
         Tag::setDefault('x_name', '');
         expect($actual)->equals($expected);
     });
 }
Beispiel #12
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 () {
         Tag::resetInput();
         $url = "http://phalconphp.com/en/";
         $name = 'x_name';
         $actual = Tag::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 () {
         Tag::resetInput();
         $options = ["http://phalconphp.com/en/", 'x_name', false];
         $actual = Tag::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 () {
         Tag::resetInput();
         $options = ["http://phalconphp.com/en/", 'text' => 'x_name', 'local' => false];
         $actual = Tag::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 () {
         Tag::resetInput();
         $url = "mailto:someone@phalconphp.com";
         $name = '*****@*****.**';
         $actual = Tag::linkTo($url, $name, false);
         $expected = '<a href="mailto:someone@phalconphp.com">someone@phalconphp.com</a>';
         expect($actual)->equals($expected);
     });
 }