예제 #1
0
 public function testLessOrEqualComparison()
 {
     $data = [12345 => 12345, 12344 => 12345];
     $isValid = true;
     foreach ($data as $val => $compVal) {
         $valid = Validator::validateFor('compare', $val, ['compareValue' => $compVal, 'operator' => '<='])->isValid;
         if (!$valid) {
             $isValid = false;
         }
     }
     $this->assertTrue($isValid);
 }
예제 #2
0
 /**
  * @expectedException \mysqli_sql_exception
  */
 public function testIsExceptionThrownOnEmptyConnectionParams()
 {
     Validator::validateFor('unique', '123', ['table' => 'table', 'column' => 'column']);
 }
예제 #3
0
 public function testIsLessThanAllowedValid()
 {
     $isValid = Validator::validateFor('number', 656.35, ['min' => 657])->isValid;
     $this->assertFalse($isValid);
 }
예제 #4
0
 public function testIsStrictComparisonWorking()
 {
     $isValid = Validator::validateFor('in', "5", ['range' => range(1, 5), 'strict' => true])->isValid;
     $this->assertFalse($isValid);
 }
예제 #5
0
 public function testIsEqualToRequiredValueUsingStrictComparison()
 {
     $isValid = Validator::validateFor('required', '1', ['requiredValue' => 1, 'strict' => true])->isValid;
     $this->assertFalse($isValid);
 }
예제 #6
0
 public function testStrictAnythingElseIsValid()
 {
     $data = ['notBool1' => 'bar', 'notBool2' => 2, 'notBool3' => 123.456, 'notBool4' => true, 'notBool5' => null];
     $isValid = Validator::validateFor('boolean', $data, ['strict' => true])->isValid;
     $this->assertFalse($isValid);
 }
예제 #7
0
 public function testIsValidWitCountryCode()
 {
     $isValid = Validator::validateFor('phone', '+999 55555555')->isValid;
     $this->assertTrue($isValid);
 }
예제 #8
0
 public function testIsProperFileValidationWorking()
 {
     $data = ['testFile' => ['name' => 'testfile.txt', 'type' => $this->mimeType, 'size' => $this->size, 'tmp_name' => $this->path, 'error' => 0]];
     $isValid = Validator::validateFor('file', $data, ['extensions' => ['txt']])->isValid;
     $this->assertTrue($isValid);
 }
예제 #9
0
 public function testIsEnabledIDNCheckWorking()
 {
     $isValid = Validator::validateFor('url', 'http://täst.de', ['enableIDN' => true])->isValid;
     $this->assertTrue($isValid);
 }
예제 #10
0
 public function testIsStringValidWithRestrictions()
 {
     $isValid = Validator::validateFor('string', '123qwe456rty', ['min' => 6, 'max' => 20])->isValid;
     $this->assertTrue($isValid);
 }
예제 #11
0
 public function testIsEmptyValueValidOnSingleValidation()
 {
     $isValid = Validator::validateFor('phone', '');
     $this->assertFalse($isValid->isValid, $isValid->lastError);
 }
예제 #12
0
 public function testIsEmailValid()
 {
     $isValid = Validator::validateFor('email', '*****@*****.**', ['checkDNS' => true])->isValid;
     $this->assertTrue($isValid);
 }