Skip to content

Commit

Permalink
Merge db46ba6 into 3be404d
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberro committed Nov 4, 2016
2 parents 3be404d + db46ba6 commit 95dee2d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
17 changes: 6 additions & 11 deletions lib/Doctrine/ODM/MongoDB/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,30 +403,25 @@ public function dropDocumentDatabase($documentName)

/**
* Create all the mapped document databases in the metadata factory.
*
* @deprecated document databases must not be created, databases are created automatically
*/
public function createDatabases()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->createDocumentDatabase($class->name);
}
return;
}

/**
* Create the document database for a mapped class.
*
* @param string $documentName
* @throws \InvalidArgumentException
*
* @deprecated document databases must not be created, databases are created automatically
*/
public function createDocumentDatabase($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
throw new \InvalidArgumentException('Cannot delete document indexes for mapped super classes or embedded documents.');
}
$this->dm->getDocumentDatabase($documentName)->execute('function() { return true; }');
return;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ protected function processCollection(SchemaManager $sm)

protected function processDocumentDb(SchemaManager $sm, $document)
{
$sm->createDocumentDatabase($document);
return;
}

protected function processDb(SchemaManager $sm)
{
$sm->createDatabases();
return;
}

protected function processDocumentIndex(SchemaManager $sm, $document)
Expand Down
13 changes: 0 additions & 13 deletions tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,6 @@ public function testDropDocumentCollection()
$this->schemaManager->dropDocumentCollection(\Documents\CmsArticle::class);
}

public function testCreateDocumentDatabase()
{
foreach ($this->documentDatabases as $class => $database) {
if ($class === \Documents\CmsArticle::class) {
$database->expects($this->once())->method('execute');
} else {
$database->expects($this->never())->method('execute');
}
}

$this->schemaManager->createDocumentDatabase(\Documents\CmsArticle::class);
}

public function testDropDocumentDatabase()
{
foreach ($this->documentDatabases as $class => $database) {
Expand Down

0 comments on commit 95dee2d

Please sign in to comment.