[ Index ] |
PHP Cross Reference of Web Application Component Toolkit |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package WACT_TESTS 4 * @version $Id: match.test.php,v 1.2 2004/11/12 21:25:20 jeffmoore Exp $ 5 */ 6 7 require_once 'rule.inc.php'; 8 require_once WACT_ROOT . 'validation/rules/match.inc.php'; 9 10 class MatchRuleTestCase extends ValidationRuleTestCase { 11 function MatchRuleTestCase($name = 'MatchRuleTestCase') { 12 $this->UnitTestCase($name); 13 } 14 function testMatchRule() { 15 $this->validator->addRule(new matchRule('testfield', 'testmatch')); 16 17 $Data =& new DataSpace(); 18 $Data->set('testfield', 'peaches'); 19 $Data->set('testmatch', 'peaches'); 20 21 $this->ErrorList->expectNever('addError'); 22 23 $this->validator->validate($Data); 24 $this->assertTrue($this->validator->IsValid()); 25 } 26 function testMatchRuleEmpty() { 27 $this->validator->addRule(new matchRule('testfield', 'testmatch')); 28 29 $Data =& new DataSpace(); 30 31 $this->ErrorList->expectNever('addError'); 32 33 $this->validator->validate($Data); 34 $this->assertTrue($this->validator->IsValid()); 35 } 36 function testMatchRuleEmpty2() { 37 $this->validator->addRule(new matchRule('testfield', 'testmatch')); 38 39 $Data =& new DataSpace(); 40 $Data->set('testfield', 'peaches'); 41 42 $this->ErrorList->expectNever('addError'); 43 44 $this->validator->validate($Data); 45 $this->assertTrue($this->validator->IsValid()); 46 } 47 function testMatchRuleEmpty3() { 48 $this->validator->addRule(new matchRule('testfield', 'testmatch')); 49 50 $Data =& new DataSpace(); 51 $Data->set('testmatch', 'peaches'); 52 53 $this->ErrorList->expectNever('addError'); 54 55 $this->validator->validate($Data); 56 $this->assertTrue($this->validator->IsValid()); 57 } 58 function testMatchRuleFailure() { 59 $this->validator->addRule(new matchRule('testfield', 'testmatch')); 60 61 $Data =& new DataSpace(); 62 $Data->set('testfield', 'peaches'); 63 $Data->set('testmatch', 'cream'); 64 65 $this->ErrorList->expectOnce('addError', array('validation', 'NO_MATCH', array('Field'=>'testfield', 'MatchField' => 'testmatch'))); 66 67 $this->validator->validate($Data); 68 $this->assertFalse($this->validator->IsValid()); 69 } 70 } 71 72 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 28 19:36:09 2004 | Cross-referenced by PHPXref 0.5 |