Skip to content

Commit

Permalink
added shutdown function to remove test db
Browse files Browse the repository at this point in the history
  • Loading branch information
kriswallsmith committed Dec 20, 2011
1 parent 68e772b commit 37eb381
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
16 changes: 3 additions & 13 deletions Tests/Validator/Constraints/UniqueValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,9 @@ protected function setUp()
__DIR__ . '/../DependencyInjection/Fixtures/Bundles/AnnotationsBundle/Document'
));

$this->dropDocumentCollection();
}

protected function tearDown()
{
if ($this->documentManager) {
$this->dropDocumentCollection();
}
$this->documentManager
->getDocumentCollection('Symfony\Bundle\DoctrineMongoDBBundle\Tests\Fixtures\Validator\Document')
->drop();
}

public function testValidateUniquenessForScalarField()
Expand Down Expand Up @@ -223,11 +218,6 @@ public function testEmbeddedDocumentIsNotUnsupported()
$violationsList = $validator->validate(new EmbeddedDocument());
}

private function dropDocumentCollection()
{
$this->documentManager->getDocumentCollection('Symfony\Bundle\DoctrineMongoDBBundle\Tests\Fixtures\Validator\Document')->drop();
}

private function createMockContainer($documentManagerId = self::DEFAULT_DOCUMENT_MANAGER)
{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
Expand Down
8 changes: 8 additions & 0 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@
} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
require_once $file;
}

register_shutdown_function(function() {
try {
$mongo = new Mongo();
$mongo->doctrine->drop();
} catch (\MongoException $e) {
}
});

0 comments on commit 37eb381

Please sign in to comment.