Skip to content

Commit

Permalink
Merge branch '2.0'
Browse files Browse the repository at this point in the history
Conflicts:
	Tests/Form/Type/DocumentTypeTest.php
	Tests/Validator/Constraints/UniqueValidatorTest.php
  • Loading branch information
kriswallsmith committed Dec 20, 2011
2 parents e29bea4 + 37eb381 commit d7d26e3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
5 changes: 5 additions & 0 deletions Tests/Form/Type/DocumentTypeTest.php
Expand Up @@ -44,6 +44,11 @@ protected function setUp()
if (!class_exists('Doctrine\\ODM\\MongoDB\\Version')) {
$this->markTestSkipped('Doctrine MongoDB ODM is not available.');
}
try {
new \Mongo();
} catch (\MongoException $e) {
$this->markTestSkipped('Unable to connect to Mongo.');
}

$this->documentManager = TestCase::createTestDocumentManager();
$this->documentManager->createQueryBuilder(self::DOCUMENT_CLASS)
Expand Down
4 changes: 2 additions & 2 deletions Tests/Security/DocumentUserProviderTest.php
Expand Up @@ -26,13 +26,13 @@ class DocumentUserProviderTest extends TestCase

protected function setUp()
{
parent::setUp();

$this->documentManager = TestCase::createTestDocumentManager();
$this->documentManager->createQueryBuilder(self::DOCUMENT_CLASS)
->remove()
->getQuery()
->execute();

parent::setUp();
}

public function testRefreshUserGetsUserByIdentifier()
Expand Down
5 changes: 5 additions & 0 deletions Tests/TestCase.php
Expand Up @@ -29,6 +29,11 @@ protected function setUp()
if (!class_exists('Doctrine\\ODM\\MongoDB\\Version')) {
$this->markTestSkipped('Doctrine MongoDB ODM is not available.');
}
try {
new \Mongo();
} catch (\MongoException $e) {
$this->markTestSkipped('Unable to connect to Mongo.');
}
}

/**
Expand Down
16 changes: 3 additions & 13 deletions Tests/Validator/Constraints/UniqueValidatorTest.php
Expand Up @@ -35,12 +35,9 @@ protected function setUp()
__DIR__ . '/../DependencyInjection/Fixtures/Bundles/AnnotationsBundle/Document'
));

$this->dropDocumentCollection();
}

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

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

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

private function createMockRegistry($documentManagerName = null)
{
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
Expand Down
8 changes: 8 additions & 0 deletions Tests/bootstrap.php
Expand Up @@ -17,3 +17,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 d7d26e3

Please sign in to comment.