[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/view/tests/cases/ -> lmbWactViewTest.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/view/src/lmbWactView.class.php');
  10  
  11  class lmbWactViewTest extends lmbWactTestCase
  12  {
  13    function setUp()
  14    {
  15      parent :: setUp();
  16      $this->toolkit->setWactLocator($this->locator);
  17    }
  18  
  19    function testRenderSimpleVars()
  20    {
  21      $template = '{$hello}{$again}';
  22  
  23      $this->registerTestingTemplate($path = '/limb/simple_view.html', $template);
  24  
  25      $view = new lmbWactView($path);
  26      $view->setCacheDir(LIMB_VAR_DIR . '/compiled');
  27      $view->set('hello', 'Hello message!');
  28      $view->set('again', 'Hello again!');
  29  
  30      $view->render();
  31  
  32      $this->assertEqual($view->render(), 'Hello message!Hello again!');
  33    }
  34  
  35    function testRenderForms()
  36    {
  37      $template = '{$hello}'.
  38                  '<form id="form1" name="form1" runat="server"><input type="text" name="title" title="Title" /></form>'.
  39                  '<form id="form2" name="form2" runat="server"></form>';
  40  
  41      $this->registerTestingTemplate($path = '/limb/form_view.html', $template);
  42  
  43      $view = new lmbWactView($path);
  44      $view->setCacheDir(LIMB_VAR_DIR . '/compiled');
  45      $view->set('hello', 'Hello world!');
  46  
  47      $error_list = new lmbErrorList();
  48      $error_list->addError('An error in {Field} with {Value}', array('Field' => 'title'), array('Value' => 'value'));
  49  
  50      $view->setFormDatasource('form1', $form1 = new lmbSet());
  51      $view->setFormErrors('form1', $error_list);
  52  
  53      $view->setFormDatasource('form2', $form2 = new lmbSet());
  54  
  55      $this->assertEqual($view->render(),
  56                         'Hello world!'.
  57                         '<form id="form1" name="form1"><input type="text" name="title" title="Title" value="" /></form>'.
  58                         '<form id="form2" name="form2"></form>');
  59  
  60      $template = $view->getWACTTemplate();
  61      $form1_component = $template->findChild('form1');
  62      $this->assertReference($form1_component->getDataSource(), $form1);
  63      $this->assertEqual($form1_component->getErrorsDataSet()->export(), $error_list->getReadable()->export());
  64      $this->assertEqual($form1_component->getErrorsDataSet()->at(0)->getMessage(),
  65                         'An error in "Title" with value');
  66  
  67      $form2_component = $template->findChild('form2');
  68      $this->assertReference($form2_component->getDataSource(), $form2);
  69    }
  70  }
  71  
  72  ?>


Generated: Tue Oct 7 05:02:03 2008 Cross-referenced by PHPXref 0.7