ValidatorTest.php 738 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. use Laravel\Validation\Validator;
  3. class ValidatorTest extends PHPUnit_Framework_TestCase {
  4. public function test_simple_group_of_validations()
  5. {
  6. $rules = array(
  7. 'email' => 'required|email',
  8. 'password' => 'required|confirmed|min:6',
  9. 'name' => 'required|alpha',
  10. );
  11. $attributes = array(
  12. 'email' => 'taylorotwell',
  13. 'password' => 'something',
  14. 'password_confirmation' => 'something',
  15. 'name' => 'taylor5',
  16. );
  17. $messages = array('name_alpha' => 'The name must be alphabetic!');
  18. $validator = Validator::make($attributes, $rules, $messages);
  19. $this->assertFalse($validator->valid());
  20. $this->assertFalse($validator->errors->has('password'));
  21. }
  22. }