Permalink
Browse files

Add email validator test

  • Loading branch information...
1 parent e8b06d6 commit f7f2483e0929ab2bf94f79218eaa9c830e6e20dc @c9s committed Sep 19, 2012
Showing with 9 additions and 44 deletions.
  1. +9 −0 ext/tests/01_email_validator.phpt
  2. +0 −44 ext/tests/bench_stringlength.php
@@ -0,0 +1,9 @@
+--TEST--
+Email Validator Test
+--FILE--
+<?php
+$validator = new ValidationKit\EmailValidator;
+$bool = $validator->validate('abc@google.com');
+var_dump($bool);
+--EXPECT--
+bool(true)
@@ -1,44 +0,0 @@
-<?php
-
-if(true) {
- dl("validationkit.so");
-}else {
- require('Validator.php');
- require('StringLengthValidator.php');
- require('StringValidator.php');
-}
-
-$e = new ValidationKit\EmailValidator();
-
- $start = microtime(true);
- $stringValidator = new \ValidationKit\StringLengthValidator(array("max"=>20, "min"=>5));
-
- $validCount = 0;
- $invalidCount =0;
-
- for ($i=0; $i < 5000; $i++) {
- $str = str_repeat("hello", rand(1,6));
- $r = $stringValidator->validate($str);
- if ($r) $validCount++;
- else $invalidCount++;
- }
- $end = microtime(true);
-
- printf("valid = %04d, invalid = %04d, ms = %s \n", $validCount, $invalidCount, ($end-$start));
-
- $start = microtime(true);
- $stringValidator = new \ValidationKit\StringValidator(array("ends_with"=>"LIN", "ignore_case"=>true));
-
- $validCount = 0;
- $invalidCount =0;
-
- for ($i=0; $i < 5000; $i++) {
- $str = str_repeat("hello", rand(1,6)). " lin" ;
- $r = $stringValidator->validate($str);
- if ($r) $validCount++;
- else $invalidCount++;
- }
- $end = microtime(true);
-
- printf("valid = %04d, invalid = %04d, ms = %s \n", $validCount, $invalidCount, ($end-$start));
-

0 comments on commit f7f2483

Please sign in to comment.