/** * 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); }