/**
  * Nested transaction calls
  *
  * @param DboTestSource $db
  * @return void
  */
 protected function _runTransactions($db)
 {
     $db->begin();
     $db->begin();
     $db->commit();
     $db->begin();
     $db->rollback();
     $db->commit();
 }
Exemplo n.º 2
0
 /**
  * Tests that transaction commands are logged
  *
  * @return void
  **/
 public function testTransactionLogging()
 {
     $conn = $this->getMock('MockPDO');
     $db = new DboTestSource();
     $db->setConnection($conn);
     $conn->expects($this->exactly(2))->method('beginTransaction')->will($this->returnValue(true));
     $conn->expects($this->once())->method('commit')->will($this->returnValue(true));
     $conn->expects($this->once())->method('rollback')->will($this->returnValue(true));
     $db->begin();
     $log = $db->getLog();
     $expected = array('query' => 'BEGIN', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => '');
     $this->assertEquals($expected, $log['log'][0]);
     $db->commit();
     $expected = array('query' => 'COMMIT', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => '');
     $log = $db->getLog();
     $this->assertEquals($expected, $log['log'][0]);
     $db->begin();
     $expected = array('query' => 'BEGIN', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => '');
     $log = $db->getLog();
     $this->assertEquals($expected, $log['log'][0]);
     $db->rollback();
     $expected = array('query' => 'ROLLBACK', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => '');
     $log = $db->getLog();
     $this->assertEquals($expected, $log['log'][0]);
 }