Index: trunk/tests/FormValidatorTest.php
===================================================================
--- trunk/tests/FormValidatorTest.php	(revision 137)
+++ trunk/tests/FormValidatorTest.php	(revision 144)
@@ -33,10 +33,13 @@
     function test_geterrorlist()
     {
-        $this->FormValidator->geterrorlist();
+        $this->FormValidator->addError('some_field', _("This is an error."), MSG_ERR, __FILE__, __LINE__);
+        $err_list = $this->FormValidator->geterrorlist();
+        $this->assertTrue($err_list[0]['message'] === _("This is an error."));
     }
 
     function test_adderror()
     {
-        $this->FormValidator->addError('name', _("This is an error."), MSG_ERR, __FILE__, __LINE__);
+        $this->FormValidator->addError('some_field', _("This is an error."), MSG_ERR, __FILE__, __LINE__);
+        $this->assertTrue($this->FormValidator->errors[0]['message'] === _("This is an error."));
     }
 
@@ -45,9 +48,12 @@
         $result = $this->FormValidator->anyerrors();
         $this->assertFalse($result);
+        $this->FormValidator->addError('some_field', _("This is an error."), MSG_ERR, __FILE__, __LINE__);
+        $result = $this->FormValidator->anyerrors();
+        $this->assertTrue($result);
     }
 
     function test_reseterrorlist()
     {
-        $this->FormValidator->addError('name', _("This is an error."), MSG_ERR, __FILE__, __LINE__);
+        $this->FormValidator->addError('some_field', _("This is an error."), MSG_ERR, __FILE__, __LINE__);
         $this->FormValidator->reseterrorlist();
         $this->assertFalse($this->FormValidator->anyerrors());
@@ -56,5 +62,5 @@
     function test_printerrormessages()
     {
-        $this->FormValidator->addError('name', _("This is an error."), MSG_ERR, __FILE__, __LINE__);
+        $this->FormValidator->addError('some_field', _("This is an error."), MSG_ERR, __FILE__, __LINE__);
         ob_start();
         $this->FormValidator->printerrormessages();
@@ -65,7 +71,7 @@
     function test_err()
     {
-        $this->FormValidator->addError('name', _("This is an error."), MSG_ERR, __FILE__, __LINE__);
+        $this->FormValidator->addError('some_field', _("This is an error."), MSG_ERR, __FILE__, __LINE__);
         ob_start();
-        $this->FormValidator->err('name', 'printthis');
+        $this->FormValidator->err('some_field', 'printthis');
         $result = ob_get_clean();
         $this->assertContains('printthis', $result);
@@ -74,75 +80,194 @@
     function test_notempty()
     {
-        $this->FormValidator->isEmpty('name', _("Error message"));
+        // This should not generate any error.
+        $_POST['some_field'] = 'a non empty string';
+        $this->FormValidator->isempty('some_field', _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = '';
+        $this->FormValidator->isempty('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_isempty()
     {
-        $result = $this->FormValidator->isempty('name', _("Error message"));
+        // This should not generate any error.
+        $_POST['some_field'] = 'a non empty string';
+        $this->FormValidator->isempty('some_field', _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = '';
+        $this->FormValidator->isempty('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_isstring()
     {
-        $result = $this->FormValidator->isstring('name', _("Error message"));
+        // This should not generate any error.
+        $_POST['some_field'] = 'this is a string';
+        $this->FormValidator->isstring('some_field', _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = 12.3248; // not a string.
+        $this->FormValidator->isstring('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_isnumber()
     {
-        $result = $this->FormValidator->isnumber('name', _("Error message"));
+        // This should not generate any error.
+        $_POST['some_field'] = '1234.453';
+        $this->FormValidator->isnumber('some_field', _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = 'not a number';
+        $this->FormValidator->isnumber('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_isinteger()
     {
-        $result = $this->FormValidator->isinteger('name', _("Error message"));
+        // This should not generate any error.
+        $_POST['some_field'] = '1234';
+        $this->FormValidator->isinteger('some_field', _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = '1234.1';
+        $this->FormValidator->isinteger('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_isfloat()
     {
-        $result = $this->FormValidator->isfloat('name', _("Error message"));
+        // This should not generate any error.
+        $_POST['some_field'] = '123.1234';
+        $this->FormValidator->isfloat('some_field', _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = 'some falsity';
+        $this->FormValidator->isfloat('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_isarray()
     {
-        $result = $this->FormValidator->isarray('name', _("Error message"));
+        // This should not generate any error.
+        $_POST['some_field'] = array('asdf', 123);
+        $this->FormValidator->isarray('some_field', _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = 'some falsity';
+        $this->FormValidator->isarray('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_checkregex()
     {
-        $result = $this->FormValidator->checkregex('name', '/\w/', true, _("Error message"));
+        // This should not generate any error.
+        $_POST['some_field'] = '1234abcd';
+        $this->FormValidator->checkregex('some_field', '/\d{4}[a-d]{4}/', true, _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This should not generate any error.
+        $_POST['some_field'] = 'no digits here';
+        $this->FormValidator->checkregex('some_field', '/\d/', false, _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = 'oops, a d1git';
+        $this->FormValidator->checkregex('some_field', '/\d/', false, _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_stringlength()
     {
-        $this->FormValidator->stringLength('name', 0, 255, _("Error message"));
+        // This should not generate any error.
+        $_POST['some_field'] = 'some truth';
+        $this->FormValidator->stringLength('some_field', 0, 255, _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = 'some falsity';
+        $this->FormValidator->stringLength('some_field', 0, 4, _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_numericrange()
     {
-        $this->FormValidator->numericrange('name', 0, 255, _("Error message"));
+        // This should not generate any error.
+        $_POST['some_field'] = '12';
+        $this->FormValidator->numericrange('some_field', 3, 22, _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = '12';
+        $this->FormValidator->numericrange('some_field', 300, 2200, _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_validateemail()
     {
-        $this->FormValidator->validateemail('name');
+        // This should not generate any error.
+        $_POST['some_field'] = 'Quinn the Kook <quinn@strangecode.com>';
+        $this->FormValidator->validateemail('some_field', _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+                
+        // This one is an error!
+        $_POST['some_field'] = 'quinn@kook.com.';
+        $this->FormValidator->validateemail('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_validatephone()
     {
-        $this->FormValidator->validatephone('name');
+        // This should not generate any error.
+        $_POST['some_field'] = '+1 (530) 555-1212';
+        $this->FormValidator->validatephone('some_field', _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = 'd321/654*9875 ';
+        $this->FormValidator->validatephone('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_validatestrdate()
     {
-        $this->FormValidator->validatestrdate('name');
+        // This should not generate any error.
+        $_POST['some_field'] = 'next tuesday';
+        $this->FormValidator->validatestrdate('some_field', _("Error message"));
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = 'in a galaxy far far away';
+        $this->FormValidator->validatestrdate('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
     function test_validateccnumber()
     {
-        $this->FormValidator->validateccnumber('name');
-    }
-
-    function test_validatefile()
-    {
-        $this->FormValidator->validatefile('name');
+        // This should not generate any error.
+        $_POST['some_field'] = '2323-2005-7766-3554';
+        $this->FormValidator->validateccnumber('some_field', null);
+        $this->assertFalse($this->FormValidator->anyerrors());
+        
+        // This one is an error!
+        $_POST['some_field'] = '1234 1234 1234 1234';
+        $this->FormValidator->validateccnumber('some_field', null);
+        $this->assertTrue($this->FormValidator->anyerrors());
+    }
+
+    function test_fileuploaded()
+    {
+        // This one is an error!
+        $this->FormValidator->fileUploaded('some_field', _("Error message"));
+        $this->assertTrue($this->FormValidator->anyerrors());
     }
 
