public function test_validates_uniqueness_of_with_multiple_fields_is_not_unique() { BookValidations::$validates_uniqueness_of[0] = array(array('name', 'special')); $book1 = BookValidations::first(); $book2 = new BookValidations(array('name' => $book1->name, 'special' => $book1->special)); $this->assert_false($book2->is_valid()); $this->assert_equals(array('Name and special must be unique'), $book2->errors->full_messages()); }
public function test_model_is_nulled_out_to_prevent_memory_leak() { $book = new BookValidations(); $book->is_valid(); $this->assert_true(strpos(serialize($book->errors), 'model";N;') !== false); }
public function test_validations_takes_strings() { BookValidations::$validates_presence_of = array('numeric_test', array('special'), 'name'); $book = new BookValidations(array('numeric_test' => 1, 'special' => 1)); $this->assert_false($book->is_valid()); }
public function test_full_messages() { $book = new BookValidations(); $book->is_valid(); $this->assert_equals(array("Name can't be blank"), array_values($book->errors->full_messages(array('hash' => true)))); }