[pLog-svn] r3928 - plog/trunk/class/test/tests/data/validator
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sun Sep 3 17:10:24 GMT 2006
Author: oscar
Date: 2006-09-03 17:10:23 +0000 (Sun, 03 Sep 2006)
New Revision: 3928
Added:
plog/trunk/class/test/tests/data/validator/emailvalidator_test.class.php
Log:
added a test case for the EmailValidator class.
Added: plog/trunk/class/test/tests/data/validator/emailvalidator_test.class.php
===================================================================
--- plog/trunk/class/test/tests/data/validator/emailvalidator_test.class.php 2006-09-02 22:17:45 UTC (rev 3927)
+++ plog/trunk/class/test/tests/data/validator/emailvalidator_test.class.php 2006-09-03 17:10:23 UTC (rev 3928)
@@ -0,0 +1,106 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/emailvalidator.class.php" );
+
+ /**
+ * \ingroup Test
+ *
+ * Test case for the EmailValidator class
+ */
+ class EmailValidator_Test extends LifeTypeTestCase
+ {
+ function setUp()
+ {
+ // a signed and an unsigned validator
+ $this->v = new EmailValidator();
+ }
+
+ /**
+ * domain with only numbers
+ */
+ function testDomainOnlyNumbers()
+ {
+ $this->assertTrue( $this->v->validate( "whatever at 123.com" ));
+ }
+
+ /**
+ * blanks in the address without double quotes
+ */
+ function testWithBlanksInAddressWithoutQuotes()
+ {
+ $this->assertFalse( $this->v->validate( "this does not at work.com" ));
+ }
+
+ /**
+ * blanks in the address without double quotes
+ */
+ function testWithBlanksInAddressWithQuotes()
+ {
+ $this->assertTrue( $this->v->validate( "\"this should \"@work.com" ));
+ }
+
+ /**
+ * normal address
+ */
+ function testNormal()
+ {
+ $this->assertTrue( $this->v->validate( "normal at address.com" ));
+ }
+
+ /**
+ * domain is an IP address
+ */
+ function testDomainWithIPAddress()
+ {
+ $this->assertTrue( $this->v->validate( "address at 124.33.12.10" ));
+ $this->assertTrue( $this->v->validate( "address@[124.33.12.10]" ));
+ }
+
+ /**
+ * domain is not a valid IP address
+ */
+ function testDomainWithInvalidIPAddress()
+ {
+ $this->assertFalse( $this->v->validate( "address at 259.445.343.4" ));
+ $this->assertFalse( $this->v->validate( "address at 259.445.343.4]" ));
+ $this->assertFalse( $this->v->validate( "address@[259.445.343.4]" ));
+ }
+
+ /**
+ * domain has dashes in the name
+ */
+ function testDomainWithDashes()
+ {
+ $this->assertTrue( $this->v->validate( "address at my-domain-with-dashes.com" ));
+ $this->assertFalse( $this->v->validate( "address at my-domain-with-dashes-.com" ));
+ $this->assertFalse( $this->v->validate( "address at -my-domain-with-dashes.com" ));
+ }
+
+ /**
+ * address with dashes
+ */
+ function testAddressWithDashes()
+ {
+ $this->assertTrue( $this->v->validate( "address-with-dashes at domain.com" ));
+ $this->assertTrue( $this->v->validate( "address-with-dashes- at domain.com" ));
+ }
+
+ /**
+ * domain has several subdomains
+ */
+ function testDomainWithSeveralSubdomains()
+ {
+ $this->assertTrue( $this->v->validate( "address at my.domain.with.several.subdomains.com" ));
+ }
+
+ /**
+ * test an empty address
+ */
+ function testEmptyAddress()
+ {
+ $this->assertFalse( $this->v->validate( "\" \"@domain.com" ));
+ $this->assertFalse( $this->v->validate( " @domain.com" ));
+ }
+ }
+?>
\ No newline at end of file
More information about the pLog-svn
mailing list