/** * testUpdateAllWithoutForeignKey * * @return void */ public function testUpdateAllWithoutForeignKey() { $this->skipIf(!$this->db instanceof Mysql, 'Currently, there is no way of doing joins in an update statement in postgresql'); $this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll'); $ProductUpdateAll = new ProductUpdateAll(); $conditions = array('Group.name' => 'group one'); $ProductUpdateAll->bindModel(array('belongsTo' => array('Group' => array('className' => 'GroupUpdateAll')))); $ProductUpdateAll->belongsTo = array('Group' => array('className' => 'GroupUpdateAll', 'foreignKey' => false, 'conditions' => 'ProductUpdateAll.groupcode = Group.code')); $ProductUpdateAll->updateAll(array('name' => "'new product'"), $conditions); $resultsFkFalse = $ProductUpdateAll->find('all', array('conditions' => array('ProductUpdateAll.name' => 'new product'))); $expected = array('0' => array('ProductUpdateAll' => array('id' => 1, 'name' => 'new product', 'groupcode' => 120, 'group_id' => 1), 'Group' => array('id' => 1, 'name' => 'group one', 'code' => 120)), '1' => array('ProductUpdateAll' => array('id' => 2, 'name' => 'new product', 'groupcode' => 120, 'group_id' => 1), 'Group' => array('id' => 1, 'name' => 'group one', 'code' => 120))); $this->assertEquals($expected, $resultsFkFalse); }
/** * test that saveAll behaves like plain save() when suplied empty data * * @link http://cakephp.lighthouseapp.com/projects/42648/tickets/277-test-saveall-with-validation-returns-incorrect-boolean-when-saving-empty-data * @access public * @return void */ function testSaveAllEmptyData() { $this->loadFixtures('Article', 'ProductUpdateAll', 'Comment', 'Attachment'); $model = new Article(); $result = $model->saveAll(array(), array('validate' => 'first')); $this->assertFalse(empty($result)); $model = new ProductUpdateAll(); $result = $model->saveAll(array()); $this->assertFalse($result); }