/**
  * Test lookup values.
  *
  * @param Connection $connection
  *   The connection to perform tests on.
  *
  * @dataProvider connectionDataProvider
  */
 public function testLookupMetadata(Connection $connection)
 {
     $indexer = new Indexer($connection);
     $connection->startTransaction();
     $operation1 = $connection->addMetadata('value', 'value1');
     $operation2 = $connection->addMetadata('value', 'value2');
     $expected = [$operation1->idx($connection) => 'value1', $operation2->idx($connection) => 'value2'];
     $indexer->index($operation1, 'test1');
     $indexer->index($operation2, 'test1');
     $check = $indexer->lookupMetadata('test1', 'value');
     $this->assertSame($expected, $check, 'Operations not found during lookup.');
 }
print "Started inner transaction\n";
$indexer->index($connection->addMetadata('value', 'value3'), 'test1');
$indexer->index($connection->addMetadata('value', 'value3'), 'test2');
print "Added data to indexer\n";
foreach ($indexer->lookup('test1') as $operation) {
    print "Looked up test1 - found: " . $operation->getMetadata('value') . "\n";
}
foreach ($indexer->lookup('test2') as $operation) {
    print "Looked up test2 - found: " . $operation->getMetadata('value') . "\n";
}
// Rollback inner transaction.
$connection->rollbackTransaction();
print "Rolled back inner transaction\n";
foreach ($indexer->lookup('test1') as $operation) {
    print "Looked up test1 - found: " . $operation->getMetadata('value') . "\n";
}
foreach ($indexer->lookup('test2') as $operation) {
    print "Looked up test2 - found: " . $operation->getMetadata('value') . "\n";
}
// Easy values lookup.
var_dump($indexer->lookupMetadata('test1', 'value'));
var_dump($indexer->lookupMetadata('test2', 'value'));
// Commit inner transaction.
$connection->commitTransaction();
print "Committed outer transaction\n";
foreach ($indexer->lookup('test1') as $operation) {
    print "Looked up test1 - found: " . $operation->getMetadata('value') . "\n";
}
foreach ($indexer->lookup('test2') as $operation) {
    print "Looked up test2 - found: " . $operation->getMetadata('value') . "\n";
}