DoctrineOrmTestCase.php 1.3 KB

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