// This loop creates a new fork to set or get key values keys.
foreach ($functions as $i =>
$function) { $pid =
pcntl_fork();
if ($pid == -1
) { $this->
fail("Error forking"
);
} elseif ($pid == 0
) { Database::
addConnectionInfo('default' .
$i, 'default',
$default_connection['default'
]);
Database::
setActiveConnection('default' .
$i);
// Create a new factory using the new connection to avoid problems with
// forks closing the database connections.
$factory =
new KeyValueDatabaseFactory($this->container->
get('serialization.phpserialize'
), Database::
getConnection());
$store =
$factory->
get('test'
);
// Sleep so that all the forks start at the same time.
usleep((int) (($time_to_start -
microtime(TRUE
)) * 1000000
));
if ($function === 'getAll'
) { $this->
assertIsArray($store->
getAll());
} else { $this->
assertNull($store->
set('foo' .
$i, 'bar'
));
} exit();
} }