diff --git a/lib/Doctrine/ODM/MongoDB/SchemaManager.php b/lib/Doctrine/ODM/MongoDB/SchemaManager.php index 0685391bf3..1e07af2a61 100644 --- a/lib/Doctrine/ODM/MongoDB/SchemaManager.php +++ b/lib/Doctrine/ODM/MongoDB/SchemaManager.php @@ -373,9 +373,7 @@ public function dropDocumentCollection($documentName) if ($class->isMappedSuperclass || $class->isEmbeddedDocument) { throw new \InvalidArgumentException('Cannot delete document indexes for mapped super classes or embedded documents.'); } - $this->dm->getDocumentDatabase($documentName)->dropCollection( - $class->getCollection() - ); + $this->dm->getDocumentCollection($documentName)->drop(); } /** diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1468Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1468Test.php new file mode 100644 index 0000000000..985afe2474 --- /dev/null +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1468Test.php @@ -0,0 +1,20 @@ +dm->persist($file); + $this->dm->flush(); + $this->assertCount(1, $this->dm->getRepository(get_class($file))->findAll()); + + $this->dm->getSchemaManager()->dropCollections(); + $this->assertCount(0, $this->dm->getRepository(get_class($file))->findAll()); + } +} diff --git a/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php b/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php index dde3c2753b..f2095e37bf 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php @@ -228,13 +228,13 @@ public function testCreateCollections() public function testDropCollections() { - foreach ($this->documentDatabases as $class => $database) { + foreach ($this->documentCollections as $class => $collection) { if (in_array($class, $this->indexedClasses + $this->someNonIndexedClasses)) { - $database->expects($this->once()) - ->method('dropCollection') - ->with($this->classMetadatas[$class]->collection); + $collection->expects($this->once()) + ->method('drop') + ->with(); } elseif (in_array($class, $this->someMappedSuperclassAndEmbeddedClasses)) { - $database->expects($this->never())->method('dropCollection'); + $collection->expects($this->never())->method('drop'); } } @@ -243,13 +243,13 @@ public function testDropCollections() public function testDropDocumentCollection() { - foreach ($this->documentDatabases as $class => $database) { + foreach ($this->documentCollections as $class => $collection) { if ($class === 'Documents\CmsArticle') { - $database->expects($this->once()) - ->method('dropCollection') - ->with($this->classMetadatas[$class]->collection); + $collection->expects($this->once()) + ->method('drop') + ->with(); } else { - $database->expects($this->never())->method('dropCollection'); + $collection->expects($this->never())->method('drop'); } }