PHPUnit_TestCase($name); } function setUp() { require dirname(__FILE__) . '/_config.inc.php'; require_once '../lib/FormValidator.inc.php'; $this->FormValidator =& new FormValidator(); } function tearDown() { unset($this->FormValidator); } function test_geterrorlist() { $this->FormValidator->geterrorlist(); } function test_adderror() { $this->FormValidator->addError('name', _("This is an error."), MSG_ERR, __FILE__, __LINE__); } function test_anyerrors() { $result = $this->FormValidator->anyerrors(); $this->assertFalse($result); } function test_reseterrorlist() { $this->FormValidator->addError('name', _("This is an error."), MSG_ERR, __FILE__, __LINE__); $this->FormValidator->reseterrorlist(); $this->assertFalse($this->FormValidator->anyerrors()); } function test_printerrormessages() { $this->FormValidator->addError('name', _("This is an error."), MSG_ERR, __FILE__, __LINE__); ob_start(); $this->FormValidator->printerrormessages(); $result = ob_get_clean(); $this->assertContains('This is an error', $result); } function test_err() { $this->FormValidator->addError('name', _("This is an error."), MSG_ERR, __FILE__, __LINE__); ob_start(); $this->FormValidator->err('name', 'printthis'); $result = ob_get_clean(); $this->assertContains('printthis', $result); } function test_notempty() { $this->FormValidator->isEmpty('name', _("Error message")); } function test_isempty() { $result = $this->FormValidator->isempty('name', _("Error message")); } function test_isstring() { $result = $this->FormValidator->isstring('name', _("Error message")); } function test_isnumber() { $result = $this->FormValidator->isnumber('name', _("Error message")); } function test_isinteger() { $result = $this->FormValidator->isinteger('name', _("Error message")); } function test_isfloat() { $result = $this->FormValidator->isfloat('name', _("Error message")); } function test_isarray() { $result = $this->FormValidator->isarray('name', _("Error message")); } function test_checkregex() { $result = $this->FormValidator->checkregex('name', '/\w/', true, _("Error message")); } function test_stringlength() { $this->FormValidator->stringLength('name', 0, 255, _("Error message")); } function test_numericrange() { $this->FormValidator->numericrange('name', 0, 255, _("Error message")); } function test_validateemail() { $this->FormValidator->validateemail('name'); } function test_validatephone() { $this->FormValidator->validatephone('name'); } function test_validatestrdate() { $this->FormValidator->validatestrdate('name'); } function test_validateccnumber() { $this->FormValidator->validateccnumber('name'); } function test_validatefile() { $this->FormValidator->validatefile('name'); } } // Running the test. $suite = new PHPUnit_TestSuite('FormValidatorTest'); $result = PHPUnit::run($suite); echo $result->toString(); ?>