| [ 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 WactFormFieldErrorsTagTest extends WactTemplateTestCase 12 { 13 function testProperNesting() 14 { 15 $template = '<form:field_errors><list:list id="errors"></list></form:field_errors>'; 16 17 $this->registerTestingTemplate('/form/form_field_errors/proper_nesting.html', $template); 18 19 try 20 { 21 $page = $this->initTemplate('/form/form_field_errors/proper_nesting.html'); 22 $this->assertTrue(false); 23 } 24 catch(WactException $e){} 25 } 26 27 function testNestingListTagIsRequired() 28 { 29 $template = '<form runat="server"><form:field_errors></form:field_errors></form>'; 30 31 $this->registerTestingTemplate('/form/form_field_errors/nesting_list_tag_required.html', $template); 32 33 try 34 { 35 $page = $this->initTemplate('/form/form_field_errors/nesting_list_tag_required.html'); 36 $this->assertTrue(false); 37 } 38 catch(WactException $e){} 39 } 40 41 function testErrorsPassedToListListTag() 42 { 43 $template = '<form id="my_form" runat="server"><form:field_errors>'. 44 '<list:list id="errors"><list:item>{$id}-{$message}|</list:item></list:list>'. 45 '</form:field_errors></form>'; 46 47 $this->registerTestingTemplate('/form/form_field_errors/passed_to_list.html', $template); 48 49 $page = $this->initTemplate('/form/form_field_errors/passed_to_list.html'); 50 51 $error_list = new WactFormErrorList(); 52 $error_list->addError('Error1 text', array('FIRST' => 'field1', 'SECOND' => 'field2')); 53 $error_list->addError('Error2 text', array('FIELD' => 'field1')); 54 55 $form = $page->getChild("my_form"); 56 $form->setErrors($error_list); 57 58 $this->assertEqual($page->capture(), '<form id="my_form">field1-Error1 text|field2-Error1 text|field1-Error2 text|</form>'); 59 } 60 61 function testErrorsForSpecifiedFormElement() 62 { 63 $template = '<form id="my_form" runat="server"><form:field_errors for="field2">'. 64 '<list:list id="errors"><list:item>{$message}|</list:item></list:list>'. 65 '</form:field_errors></form>'; 66 67 $this->registerTestingTemplate('/form/form_field_errors/for_element_passed_to_list.html', $template); 68 69 $page = $this->initTemplate('/form/form_field_errors/for_element_passed_to_list.html'); 70 71 $error_list = new WactFormErrorList(); 72 $error_list->addError('Error1 text', array('FIRST' => 'field1', 'SECOND' => 'field2')); 73 $error_list->addError('Error2 text', array('FIELD' => 'field1')); 74 $error_list->addError('Error3 text', array('FIELD' => 'field2')); 75 76 $form = $page->getChild("my_form"); 77 $form->setErrors($error_list); 78 79 $this->assertEqual($page->capture(), '<form id="my_form">Error1 text|Error3 text|</form>'); 80 } 81 } 82 ?>
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 |