BaseTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Doctrine\Tests\Common\DataFixtures;
  3. use Doctrine\DBAL\Driver;
  4. use Doctrine\ORM\EntityManager;
  5. use Doctrine\ORM\Tools\Setup;
  6. use PHPUnit\Framework\TestCase;
  7. /**
  8. * Base test class
  9. *
  10. * @author Jonathan H. Wage <jonwage@gmail.com>
  11. */
  12. abstract class BaseTest extends TestCase
  13. {
  14. /**
  15. * EntityManager mock object together with
  16. * annotation mapping driver
  17. *
  18. * @return EntityManager
  19. */
  20. protected function getMockAnnotationReaderEntityManager()
  21. {
  22. $dbParams = ['driver' => 'pdo_sqlite', 'memory' => true];
  23. $config = Setup::createAnnotationMetadataConfiguration([__DIR__.'/TestEntity'], true);
  24. return EntityManager::create($dbParams, $config);
  25. }
  26. /**
  27. * EntityManager mock object together with
  28. * annotation mapping driver and pdo_sqlite
  29. * database in memory
  30. *
  31. * @return EntityManager
  32. */
  33. protected function getMockSqliteEntityManager()
  34. {
  35. $dbParams = ['driver' => 'pdo_sqlite', 'memory' => true];
  36. $config = Setup::createAnnotationMetadataConfiguration([__DIR__.'/TestEntity'], true);
  37. return EntityManager::create($dbParams, $config);
  38. }
  39. }