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); }
/** * @expectedException \mysqli_sql_exception */ public function testIsExceptionThrownOnEmptyConnectionParams() { Validator::validateFor('unique', '123', ['table' => 'table', 'column' => 'column']); }
public function testIsLessThanAllowedValid() { $isValid = Validator::validateFor('number', 656.35, ['min' => 657])->isValid; $this->assertFalse($isValid); }
public function testIsStrictComparisonWorking() { $isValid = Validator::validateFor('in', "5", ['range' => range(1, 5), 'strict' => true])->isValid; $this->assertFalse($isValid); }
public function testIsEqualToRequiredValueUsingStrictComparison() { $isValid = Validator::validateFor('required', '1', ['requiredValue' => 1, 'strict' => true])->isValid; $this->assertFalse($isValid); }
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); }
public function testIsValidWitCountryCode() { $isValid = Validator::validateFor('phone', '+999 55555555')->isValid; $this->assertTrue($isValid); }
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); }
public function testIsEnabledIDNCheckWorking() { $isValid = Validator::validateFor('url', 'http://täst.de', ['enableIDN' => true])->isValid; $this->assertTrue($isValid); }
public function testIsStringValidWithRestrictions() { $isValid = Validator::validateFor('string', '123qwe456rty', ['min' => 6, 'max' => 20])->isValid; $this->assertTrue($isValid); }
public function testIsEmptyValueValidOnSingleValidation() { $isValid = Validator::validateFor('phone', ''); $this->assertFalse($isValid->isValid, $isValid->lastError); }
public function testIsEmailValid() { $isValid = Validator::validateFor('email', '*****@*****.**', ['checkDNS' => true])->isValid; $this->assertTrue($isValid); }