| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 10 11 class WactTemplateExpressionsTest extends WactTemplateTestCase 12 { 13 function testIntegerConstant() 14 { 15 $template = '{$23}'; 16 17 $this->registerTestingTemplate('/template/expression/integer.html', $template); 18 $page = $this->initTemplate('/template/expression/integer.html'); 19 $output = $page->capture(); 20 $this->assertEqual($output, '23'); 21 } 22 23 function testFloatConstant() 24 { 25 $template = '{$1.5}'; 26 27 $this->registerTestingTemplate('/template/expression/float.html', $template); 28 $page = $this->initTemplate('/template/expression/float.html'); 29 $output = $page->capture(); 30 $this->assertEqual($output, '1.5'); 31 } 32 33 function testStringConstant() 34 { 35 $template = '{$"hello"}'; 36 37 $this->registerTestingTemplate('/template/expression/string.html', $template); 38 $page = $this->initTemplate('/template/expression/string.html'); 39 $output = $page->capture(); 40 $this->assertEqual($output, 'hello'); 41 } 42 43 function testDelimiterStringConstant() 44 { 45 $template = '{$"}"}'; 46 47 $this->registerTestingTemplate('/template/expression/string-del.html', $template); 48 $page = $this->initTemplate('/template/expression/string-del.html'); 49 $output = $page->capture(); 50 $this->assertEqual($output, '}'); 51 } 52 53 function testSingleQuoteStringConstant() 54 { 55 $template = '{$"\'"|raw}'; 56 57 $this->registerTestingTemplate('/template/expression/quote-single.html', $template); 58 $page = $this->initTemplate('/template/expression/quote-single.html'); 59 $output = $page->capture(); 60 $this->assertEqual($output, '\''); 61 } 62 63 function testDoubleQuoteStringConstant() 64 { 65 $template = '{$\'"\'|raw}'; 66 67 $this->registerTestingTemplate('/template/expression/quote-double.html', $template); 68 $page = $this->initTemplate('/template/expression/quote-double.html'); 69 $output = $page->capture(); 70 $this->assertEqual($output, '"'); 71 } 72 73 function testPath() 74 { 75 $template = '{$Data.Var}'; 76 77 $this->registerTestingTemplate('/template/expression/path.html', $template); 78 $page = $this->initTemplate('/template/expression/path.html'); 79 $page->set('Data', array('Var' => 'test')); 80 $output = $page->capture(); 81 $this->assertEqual($output, 'test'); 82 } 83 84 function testLongPath() 85 { 86 $template = '{$Data.More.Var}'; 87 88 $this->registerTestingTemplate('/template/expression/longpath.html', $template); 89 $page = $this->initTemplate('/template/expression/longpath.html'); 90 $page->set('Data', array('More' => array('Var' => 'test'))); 91 $output = $page->capture(); 92 $this->assertEqual($output, 'test'); 93 } 94 95 function testPathWithNumeric() 96 { 97 $template = '{$Data.1}'; 98 99 $this->registerTestingTemplate('/template/expression/path_with_numeric.html', $template); 100 $page = $this->initTemplate('/template/expression/path_with_numeric.html'); 101 $page->set('Data', array('first', 'second')); 102 $output = $page->capture(); 103 $this->assertEqual($output, 'second'); 104 } 105 106 function testPathWithNumericZero() 107 { 108 $template = '{$Data.0}'; 109 110 $this->registerTestingTemplate('/template/expression/path_with_numeric_zero.html', $template); 111 $page = $this->initTemplate('/template/expression/path_with_numeric_zero.html'); 112 $page->set('Data', array('first', 'second')); 113 $output = $page->capture(); 114 $this->assertEqual($output, 'first'); 115 } 116 117 function testPathWithLocalModifier() 118 { 119 $template = '<? $var1 = array("subvar" => "ivan"); ?>{$$var1.subvar|uppercase}'; 120 121 $this->registerTestingTemplate('/template/expression/path_with_local_modifier.html', $template); 122 $page = $this->initTemplate('/template/expression/path_with_local_modifier.html'); 123 $output = $page->capture(); 124 $this->assertEqual($output, 'IVAN'); 125 } 126 } 127 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jan 8 04:06:23 2009 | Cross-referenced by PHPXref 0.7 |