| [ 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 lmb_require('limb/macro/src/lmbMacroTemplate.class.php'); 10 lmb_require('limb/fs/src/lmbFs.class.php'); 11 12 class lmbMacroTemplateTest extends UnitTestCase 13 { 14 function setUp() 15 { 16 lmbFs :: rm(LIMB_VAR_DIR . '/view'); 17 lmbFs :: mkdir(LIMB_VAR_DIR . '/view'); 18 lmbFs :: mkdir(LIMB_VAR_DIR . '/view/tpl'); 19 lmbFs :: mkdir(LIMB_VAR_DIR . '/view/compiled'); 20 } 21 22 function testRenderTemplateVar() 23 { 24 $view = $this->_createView('Hello, <?$name = "Jack"?><?=@$name?>'); 25 $view->set('name', 'Bob'); 26 $this->assertEqual($view->render(), 'Hello, Bob'); 27 } 28 29 function testRenderLocalVar() 30 { 31 $view = $this->_createView('Hello, <?$name = "Jack"?><?=$name?>'); 32 $view->set('name', 'Bob'); 33 $this->assertEqual($view->render(), 'Hello, Jack'); 34 } 35 36 function testEchoVarSyntaxSugar() 37 { 38 $view = $this->_createView('Hello, <?$name = "Jack"?>{$name}'); 39 $view->set('name', 'Bob'); 40 $this->assertEqual($view->render(), 'Hello, Jack'); 41 } 42 43 function testEchoFunctionSyntaxSugar() 44 { 45 $rnd = mt_rand(); 46 $view = $this->_createView("Hello, <?function f_$rnd(){return 'Jack';}?>{f_$rnd()}"); 47 $this->assertEqual($view->render(), 'Hello, Jack'); 48 } 49 50 function _createView($tpl) 51 { 52 $file = $this->_createTemplate($tpl); 53 $view = new lmbMacroTemplate($file, LIMB_VAR_DIR . '/view/compiled'); 54 return $view; 55 } 56 57 function _createTemplate($tpl) 58 { 59 $file = LIMB_VAR_DIR . '/view/tpl/' . mt_rand() . '.phtml'; 60 file_put_contents($file, $tpl); 61 return $file; 62 } 63 } 64 65 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Nov 22 03:48:54 2008 | Cross-referenced by PHPXref 0.7 |