/** * @expectedException \Doctrine\DBAL\DBALException */ public function testExecuteCallsLoggerStopQueryOnException() { $logger = $this->getMock('\\Doctrine\\DBAL\\Logging\\SQLLogger'); $this->configuration->expects($this->once())->method('getSQLLogger')->will($this->returnValue($logger)); // Needed to satisfy construction of DBALException $this->conn->expects($this->any())->method('resolveParams')->will($this->returnValue(array())); $logger->expects($this->once())->method('startQuery'); $logger->expects($this->once())->method('stopQuery'); $this->pdoStatement->expects($this->once())->method('execute')->will($this->throwException(new \Exception("Mock test exception"))); $statement = new Statement("", $this->conn); $statement->execute(); }
public function testExecuteCallsLoggerStartQueryWithParametersWhenParamsPassedToExecute() { $name = 'foo'; $var = 'bar'; $values = array($name => $var); $types = array(); $sql = ''; $logger = $this->getMock('\\Doctrine\\DBAL\\Logging\\SQLLogger'); $logger->expects($this->once())->method('startQuery')->with($this->equalTo($sql), $this->equalTo($values), $this->equalTo($types)); $this->configuration->expects($this->once())->method('getSQLLogger')->will($this->returnValue($logger)); $statement = new Statement($sql, $this->conn); $statement->execute($values); }