Esempio n. 1
0
 /**
  * test save with transaction and ensure there is no missing rollback.
  *
  * @return void
  */
 public function testSaveTransactionNoRollback()
 {
     $this->loadFixtures('Post', 'Boat');
     $db = $this->getMock('DboSource', array('begin', 'connect', 'rollback', 'describe'));
     $db->expects($this->once())->method('describe')->will($this->returnValue(array()));
     $db->expects($this->once())->method('begin')->will($this->returnValue(true));
     $db->expects($this->once())->method('rollback');
     $Post = new TestPost();
     $Post->setDataSourceObject($db);
     $callback = array($this, 'callbackForTestSaveTransaction');
     $Post->getEventManager()->attach($callback, 'Model.beforeSave');
     $data = array('Post' => array('author_id' => 1, 'title' => 'New Fourth Post'));
     $Post->save($data, array('atomic' => true));
 }