/**
  * Test UnbufferedConnectionHelper with good driver.
  *
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  */
 public function testUnbufferedConnectionHelper()
 {
     $mockWrappedConnection = $this->getMockPDOConnection();
     $mockWrappedConnection->expects($this->once())->method('getAttribute')->with(PDO::ATTR_DRIVER_NAME)->willReturn('mysql');
     $mockWrappedConnection->expects($this->once())->method('setAttribute')->with(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY);
     $mockConnection = $this->getDbalConnection();
     $mockConnection->expects($this->exactly(2))->method('getWrappedConnection')->willReturn($mockWrappedConnection);
     $mockConnection->expects($this->once())->method('isConnected')->willReturn(false);
     $mockConnection->expects($this->once())->method('connect')->willReturn(false);
     UnbufferedConnectionHelper::unbufferConnection($mockConnection);
 }
 /**
  * Tests whether UnbufferedConnectionHelper works as intended in normal circumstances.
  *
  * @runInSeparateProcess
  */
 public function testUnbufferedConnectionHelper()
 {
     $this->importData('Import/stress.sql');
     UnbufferedConnectionHelper::unbufferConnection($this->getConnection());
     $this->getConnection()->close();
     $bufferredTimeStart = microtime();
     $statementBuff = new Statement('SELECT * FROM generator_64k', $this->getConnection());
     $statementBuff->execute();
     $bufferredTime = microtime() - $bufferredTimeStart;
     $this->getConnection()->close();
     UnbufferedConnectionHelper::unbufferConnection($this->getConnection());
     $unBufferredTimeStart = microtime();
     $statement = new Statement('SELECT * FROM generator_64k', $this->getConnection());
     $statement->execute();
     $unBufferedTime = microtime() - $unBufferredTimeStart;
     $this->getConnection()->close();
     $this->assertTrue($unBufferedTime < $bufferredTime, 'Unbuffered query should return faster after execute().');
 }