DoctrineOrmTestCase.php 1.5 KB

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