/**
  * Test if NULL value fails validation when it is not allowed.
  */
 public function testNullFailsValidationWhenNotAllowed()
 {
     $validator = new Validator($this->connection, 'users', null, null, ['email' => null]);
     $is_valid_email = $validator->email('email', false);
     $this->assertFalse($is_valid_email);
     $this->assertTrue($validator->hasErrors());
     $email_errors = $validator->getFieldErrors('email');
     $this->assertInternalType('array', $email_errors);
     $this->assertCount(1, $email_errors);
 }
 /**
  * Test if NULL value fails validation when it is not allowed.
  */
 public function testNullFailsValidationWhenNotAllowed()
 {
     $validator = new Validator($this->connection, 'users', null, null, ['age' => null]);
     $is_valid_age = $validator->greaterThan('age', $this->min_age);
     $this->assertFalse($is_valid_age);
     $this->assertTrue($validator->hasErrors());
     $age_errors = $validator->getFieldErrors('age');
     $this->assertInternalType('array', $age_errors);
     $this->assertCount(1, $age_errors);
 }
 /**
  * Test if NULL value fails validation when it is not allowed.
  */
 public function testNullFailsValidationWhenNotAllowed()
 {
     $validator = new Validator($this->connection, 'users', null, null, ['continent' => null]);
     $is_valid_continent = $validator->inArray('continent', $this->continents);
     $this->assertFalse($is_valid_continent);
     $this->assertTrue($validator->hasErrors());
     $continent_errors = $validator->getFieldErrors('continent');
     $this->assertInternalType('array', $continent_errors);
     $this->assertCount(1, $continent_errors);
 }
 /**
  * Test type check.
  */
 public function testTypeCheck()
 {
     $validator = new Validator($this->connection, 'writers', null, null, ['name' => '0']);
     $is_present = $validator->present('name');
     $this->assertTrue($is_present);
     $this->assertFalse($validator->hasErrors());
     $name_errors = $validator->getFieldErrors('name');
     $this->assertInternalType('array', $name_errors);
     $this->assertCount(0, $name_errors);
 }
 /**
  * Test if NULL value fails validation when it is not allowed.
  */
 public function testNullFailsValidationWhenNotAllowed()
 {
     $validator = new Validator($this->connection, 'users', null, null, ['homepage_url' => null]);
     $is_valid_url = $validator->url('homepage_url', false);
     $this->assertFalse($is_valid_url);
     $this->assertTrue($validator->hasErrors());
     $url_errors = $validator->getFieldErrors('homepage_url');
     $this->assertInternalType('array', $url_errors);
     $this->assertCount(1, $url_errors);
     $this->assertContains("Value of 'homepage_url' is required", $url_errors);
 }
 /**
  * Test unique where filter properly reports an error when conditions are met.
  */
 public function testErrorWhenUniqueWhereIsMatched()
 {
     $validator = new Validator($this->connection, 'writers', null, null, ['name' => 'Leo Tolstoy']);
     $is_unique = $validator->uniqueWhere('name', ['birthday < ?', new DateValue('1900-01-01')]);
     $this->assertFalse($is_unique);
     $this->assertTrue($validator->hasErrors());
     $name_errors = $validator->getFieldErrors('name');
     $this->assertInternalType('array', $name_errors);
     $this->assertCount(1, $name_errors);
 }