/** * Tests that altering data in a beforeValidate callback will lead to saving those * values in database, this time with belongsTo associations * * @return void */ public function testValidateFirstAssociatedWithBeforeValidate2() { $this->loadFixtures('Boat', 'User'); $model = new CustomBoat(); $model->validate = array('title' => array('notBlank' => array('rule' => 'notBlank', 'required' => true))); $data = array('User' => array('user' => 'foo', 'password' => 'bar'), 'CustomBoat' => array('body' => 'a test')); $result = $model->saveAll($data, array('validate' => 'first')); $this->assertTrue($result); $this->assertEquals('foo', $model->field('title', array('body' => 'a test'))); }
/** * test custom find method * * @return void */ public function testfindCustom() { $this->loadFixtures('Boat'); $Boat = new CustomBoat(); $data = array('user_id' => 3, 'title' => 'Fourth Boat', 'body' => 'Boat Body, unpublished', 'published' => 'N'); $Boat->create($data); $Boat->save(null, false); $this->assertEquals(4, $Boat->id); $result = $Boat->find('published'); $this->assertEquals(3, count($result)); $result = $Boat->find('unPublished'); $this->assertEquals(1, count($result)); }