[ Index ] |
PHP Cross Reference of Web Application Component Toolkit |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package WACT_TESTS 4 * @version $Id: url.test.php,v 1.2 2004/11/12 21:25:20 jeffmoore Exp $ 5 */ 6 7 require_once 'singlefield.inc.php'; 8 require_once WACT_ROOT . 'validation/rules/url.inc.php'; 9 10 class UrlRuleTestCase extends SingleFieldRuleTestCase { 11 function UrlRuleTestCase($name = 'UrlRuleTestCase') { 12 $this->UnitTestCase($name); 13 } 14 function testUrlRule() { 15 $this->validator->addRule(new UrlRule('testfield')); 16 17 $Data =& new DataSpace(); 18 $Data->set('testfield', 'http://www.sourceforge.net/'); 19 20 $this->ErrorList->expectNever('addError'); 21 22 $this->validator->validate($Data); 23 $this->assertTrue($this->validator->IsValid()); 24 } 25 function testUrlRuleBadScheme() { 26 $allowedSchemes = array('http'); 27 $this->validator->addRule(new UrlRule('testfield',$allowedSchemes)); 28 29 $Data =& new DataSpace(); 30 $Data->set('testfield', 'ftp://www.sourceforge.net/'); 31 32 $this->ErrorList->expectOnce('addError', array('validation', 'URL_BAD_SCHEME', array('Field'=>'testfield'), array('scheme'=>'ftp'))); 33 34 $this->validator->validate($Data); 35 $this->assertFalse($this->validator->IsValid()); 36 } 37 function testUrlRuleMissingScheme() { 38 $allowedSchemes = array('http'); 39 $this->validator->addRule(new UrlRule('testfield',$allowedSchemes)); 40 41 $Data =& new DataSpace(); 42 $Data->set('testfield', 'www.sourceforge.net/'); 43 44 $this->ErrorList->expectOnce('addError', array('validation', 'URL_MISSING_SCHEME',array('Field'=>'testfield'), NULL)); 45 46 $this->validator->validate($Data); 47 $this->assertFalse($this->validator->IsValid()); 48 } 49 function testUrlRuleDomain() { 50 $this->validator->addRule(new UrlRule('testfield')); 51 52 $Data =& new DataSpace(); 53 $Data->set('testfield', 'http://www.source--forge.net/'); 54 55 $this->ErrorList->expectOnce('addError', array('validation', 'BAD_DOMAIN_DOUBLE_HYPHENS', array('Field'=>'testfield'), NULL)); 56 57 $this->validator->validate($Data); 58 $this->assertFalse($this->validator->IsValid()); 59 } 60 } 61 62 ?>
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 |