[pLog-svn] r4952 - plog/branches/lifetype-1.2/class/test/tests/data/validator
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sat Mar 3 12:41:16 EST 2007
Author: oscar
Date: 2007-03-03 12:41:16 -0500 (Sat, 03 Mar 2007)
New Revision: 4952
Added:
plog/branches/lifetype-1.2/class/test/tests/data/validator/httpurlvalidator_test.class.php
Log:
Maybe the reason why we never used the code in the UrlFormatRule class is because it isn't very reliable... All invalid URLs from the test care are being validated as valid ones.
Added: plog/branches/lifetype-1.2/class/test/tests/data/validator/httpurlvalidator_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/data/validator/httpurlvalidator_test.class.php (rev 0)
+++ plog/branches/lifetype-1.2/class/test/tests/data/validator/httpurlvalidator_test.class.php 2007-03-03 17:41:16 UTC (rev 4952)
@@ -0,0 +1,54 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/httpurlvalidator.class.php" );
+
+ /**
+ * \ingroup Test
+ *
+ * Test cases for the HttpUrlValidator_Test class
+ */
+ class HttpUrlValidator_Test extends LifeTypeTestCase
+ {
+ var $r;
+
+ function setUp()
+ {
+ $this->v = new HttpUrlValidator();
+ }
+
+ function testValidUrls()
+ {
+ $urls = Array(
+ "http://www.lifetype.net",
+ "http://www.lifetype.net/index.php?op=Default&blogId=3",
+ "http://www.lifetype.net/#anchortest",
+ "http://localhost/",
+ "http://127.22.45.44",
+ "http://user:password@www.server.com",
+ "http://user@23.44.22.12:8050/my/very/long/server/folder/.with.several.dots",
+ "http://www.fi"
+ );
+
+ foreach( $urls as $url ) {
+ $this->assertTrue( $this->v->validate( $url ), "URL $url did not validate, although it is a valid one!" );
+ }
+ }
+
+ function testInvalidUrls()
+ {
+ $urls = Array(
+ "http://",
+ "http://www.....com",
+ "htttp://www.server.com",
+ "http://user@password@server.com",
+ "http://www.server.com/index.php¶m1=value¶m2¶m3",
+ "http://www.server.com/index.php?param1?param2?param3"
+ );
+
+ foreach( $urls as $url ) {
+ $this->assertFalse( $this->v->validate( $url ), "URL $url was validated, although it is an invalid one!" );
+ }
+ }
+ }
+?>
\ No newline at end of file
More information about the pLog-svn
mailing list