/** * Tests that altering data in a beforeValidate callback will lead to saving those * values in database * * @return void */ public function testValidateFirstAssociatedWithBeforeValidate() { $this->loadFixtures('Article', 'User'); $model = new CustomArticle(); $model->validate = array('title' => array('notempty' => array('rule' => 'notEmpty', 'required' => true))); $articles = array(array('body' => 'foo1'), array('body' => 'foo2'), array('body' => 'foo3')); $user = new User(); $user->bindModel(array('hasMany' => array('CustomArticle'))); $data = array('User' => array('user' => 'foo', 'password' => 'bar'), 'CustomArticle' => $articles); $result = $user->saveAll($data, array('validate' => 'first')); $this->assertTrue($result); $this->assertEquals('foo', $model->field('title', array('body' => 'foo1'))); $this->assertEquals('foo', $model->field('title', array('body' => 'foo2'))); $this->assertEquals('foo', $model->field('title', array('body' => 'foo3'))); }