bootstrap.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * This is bootstrap for phpUnit unit tests,
  4. * use README.md for more details
  5. *
  6. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  7. * @package Gedmo.Tests
  8. * @link http://www.gediminasm.org
  9. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  10. */
  11. if (!class_exists('PHPUnit_Framework_TestCase') ||
  12. version_compare(PHPUnit_Runner_Version::id(), '3.6') < 0
  13. ) {
  14. die('PHPUnit framework is required, at least 3.6 version');
  15. }
  16. if (!class_exists('PHPUnit_Framework_MockObject_MockBuilder')) {
  17. die('PHPUnit MockObject plugin is required, at least 1.0.8 version');
  18. }
  19. define("DB_ENGINE", getenv("DB") ?: "pgsql");
  20. define('DB_HOST', getenv("DB_HOST") ?: 'localhost');
  21. define('DB_NAME', getenv("DB_NAME") ?: 'orm_behaviors_test');
  22. define("DB_USER", getenv("DB_USER") ?: null);
  23. define("DB_PASSWD", getenv("DB_PASSWD") ?: null);
  24. define('TESTS_PATH', __DIR__);
  25. define('TESTS_TEMP_DIR', __DIR__.'/temp');
  26. define('VENDOR_PATH', realpath(__DIR__ . '/../vendor'));
  27. $loader = require(VENDOR_PATH.'/autoload.php');
  28. $loader->add('BehaviorFixtures', __DIR__.'/fixtures');
  29. Doctrine\Common\Annotations\AnnotationRegistry::registerFile(
  30. VENDOR_PATH.'/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'
  31. );
  32. $reader = new \Doctrine\Common\Annotations\AnnotationReader();
  33. $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache());
  34. $_ENV['annotation_reader'] = $reader;