TestCase.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\DoctrineMongoDBBundle\Tests;
  11. use Doctrine\ODM\MongoDB\DocumentManager;
  12. use Doctrine\MongoDB\Connection;
  13. class TestCase extends \PHPUnit_Framework_TestCase
  14. {
  15. protected function setUp()
  16. {
  17. if (!class_exists('Doctrine\\ODM\\MongoDB\\Version')) {
  18. $this->markTestSkipped('Doctrine MongoDB ODM is not available.');
  19. }
  20. }
  21. /**
  22. * @return DocumentManager
  23. */
  24. protected function createTestDocumentManager($paths = array())
  25. {
  26. $config = new \Doctrine\ODM\MongoDB\Configuration();
  27. $config->setAutoGenerateProxyClasses(true);
  28. $config->setProxyDir(\sys_get_temp_dir());
  29. $config->setHydratorDir(\sys_get_temp_dir());
  30. $config->setProxyNamespace('SymfonyTests\Doctrine');
  31. $config->setHydratorNamespace('SymfonyTests\Doctrine');
  32. $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths));
  33. $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
  34. return DocumentManager::create(new Connection(), 'test', $config);
  35. }
  36. }