public getDocumentDatabase ( string $className ) : Doctrine\MongoDB\Database | ||
$className | string | The class name. |
return | Doctrine\MongoDB\Database |
public function getDocumentDatabase($className)
{
$className = ltrim($className, '\\');
if (isset($this->documentDatabases[$className])) {
return $this->documentDatabases[$className];
}
$metadata = $this->metadataFactory->getMetadataFor($className);
$db = $metadata->getDatabase();
$db = $db ?: $this->config->getDefaultDB();
$db = $db ?: 'doctrine';
$this->documentDatabases[$className] = $this->connection->selectDatabase($db);
return $this->documentDatabases[$className];
}
protected function skipTestIfNotSharded($className) { $result = $this->dm->getDocumentDatabase($className)->command(['listCommands' => true]); if (!$result['ok']) { $this->markTestSkipped('Could not check whether server supports sharding'); } if (!array_key_exists('shardCollection', $result['commands'])) { $this->markTestSkipped('Test skipped because server does not support sharding'); } }