DoctrineOrmTestCase.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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\Tests\Component\Form;
  11. require_once __DIR__.'/TestCase.php';
  12. use Doctrine\ORM\EntityManager;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
  15. use Symfony\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension;
  16. use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
  17. class DoctrineOrmTestCase extends TestCase
  18. {
  19. protected function setUp()
  20. {
  21. parent::setUp();
  22. if (!class_exists('Doctrine\\Common\\Version')) {
  23. $this->markTestSkipped('Doctrine is not available.');
  24. }
  25. }
  26. /**
  27. * @return EntityManager
  28. */
  29. protected function createTestEntityManager($paths = array())
  30. {
  31. $config = new \Doctrine\ORM\Configuration();
  32. $config->setAutoGenerateProxyClasses(true);
  33. $config->setProxyDir(\sys_get_temp_dir());
  34. $config->setProxyNamespace('SymfonyTests\Doctrine');
  35. $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths));
  36. $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
  37. $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
  38. $params = array(
  39. 'driver' => 'pdo_sqlite',
  40. 'memory' => true,
  41. );
  42. return EntityManager::create($params, $config);
  43. }
  44. }