DoctrineOrmTestCase.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. use Symfony\Tests\Component\Form\Extension\Core\Type\TestCase;
  13. abstract class DoctrineOrmTestCase extends \PHPUnit_Framework_TestCase
  14. {
  15. protected function setUp()
  16. {
  17. if (!class_exists('Doctrine\\Common\\Version')) {
  18. $this->markTestSkipped('Doctrine is not available.');
  19. }
  20. }
  21. /**
  22. * @return EntityManager
  23. */
  24. public static 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. }