started some input validation code and unit tests for it
[gwvp.git] / unittests / inputvalidate.php
diff --git a/unittests/inputvalidate.php b/unittests/inputvalidate.php
new file mode 100644 (file)
index 0000000..a97dbb4
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+$lib_base = "../gwvplib/";
+
+// initial http file
+$WEB_ROOT_FS = realpath(dirname(__FILE__));
+$BASE_URL = dirname($_SERVER["PHP_SELF"]);
+
+global $WEB_ROOT_FS, $BASE_URL, $repo_base, $data_directory, $db_type, $db_name, $db_username, $db_password;
+
+// add gwvplib as if it were a path in ../gwvplib
+if(file_exists($lib_base)) {
+       $path = realpath($lib_base);
+       set_include_path(get_include_path().PATH_SEPARATOR.$path);
+}
+
+require_once("gwvplib.php");
+
+
+echo "Doing email validation\n";
+echo "\tasfd@asdf.com (should pass)\n";
+if(gwvp_checkEmail("asdf@asfd.com")) {
+       echo "\tpass\n";
+} else {
+       echo "\tFAIL\n";
+}
+
+echo "\tasfd@asd+af..com (should fail)\n";
+if(gwvp_checkEmail("asfd@asd+af..com")) {
+       echo "\tPASS\n";
+} else {
+       echo "\tfail\n";
+}
+
+
+?>
\ No newline at end of file