public function testSynchronizedForeignKeyIsValidIfLocalRelationIsSet() { $person = new TestPerson(); $person->synchronizeWithArray(array('Addresses' => array(array()))); $address = $person->Addresses[0]; $table = $address->getTable(); $errors = $table->validateField('person_id', $address->person_id, $address); $this->assertEqual(0, $errors->count()); }
public function Test_of_isValid() { $Person = new TestPerson(array('country' => 'ES')); $this->assertFalse($Person->isValid()); $this->assertEqual($Person->getErrors(), array('first_name' => array("can't be blank"), 'tos' => array("must be accepted"))); $Person->clearErrors(); $Person = $Person->findFirst(array('user_name = ?', 'bermi')); $Person->set('tos', 0); $this->assertFalse($Person->isValid()); $this->assertEqual($Person->getErrors(), array('email' => array("can't be blank"))); }