/**
  * Test rollback.
  *
  * @param Operation $operation
  *   The operation to perform tests on.
  *
  * @dataProvider operationDataProvider
  */
 public function testRollback(Operation $operation)
 {
     $performed = false;
     $callback = function () use(&$performed) {
         $performed = true;
         return 'performed';
     };
     $operation->onRollback($callback);
     $check = $operation->getRollbackCallbacks();
     $this->assertSame($callback, reset($check), 'Correct callback was not set.');
     $operation->rollback();
     $this->assertTrue($performed, 'Callback was not executed.');
     $check = $operation->getResult();
     $this->assertSame('performed', $check, 'Callback did not return proper result.');
 }
 /**
  * Test commit transaction.
  *
  * @param Connection $connection
  *   The connection to perform tests on.
  *
  * @dataProvider connectionDataProvider
  */
 public function testNestedTransaction(Connection $connection)
 {
     $accumulator = '';
     $operation = new Operation();
     $operation->onRollback(function ($operation, $connection) use(&$accumulator) {
         $accumulator .= 'rollback';
         if ($connection->getDepth() > 0) {
             $connection->addOperation($operation);
         }
     });
     $connection->startTransaction();
     $connection->startTransaction();
     $connection->startTransaction();
     $connection->addOperation($operation);
     $connection->rollbackTransaction();
     $connection->rollbackTransaction();
     $connection->rollbackTransaction();
     $this->assertEquals('rollbackrollbackrollback', $accumulator, 'Nested rollback was not performed.');
 }