bootstrap.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.5') < 0
  13. ) {
  14. die('PHPUnit framework is required, at least 3.5 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('TESTS_PATH', __DIR__);
  20. define('TESTS_TEMP_DIR', __DIR__.'/temp');
  21. define('VENDOR_PATH', realpath(__DIR__ . '/../vendor'));
  22. $classLoaderFile = VENDOR_PATH . '/Symfony/Component/ClassLoader/UniversalClassLoader.php';
  23. if (!file_exists($classLoaderFile)) {
  24. die('cannot find vendor, run: php bin/vendors.php');
  25. }
  26. require_once $classLoaderFile;
  27. $loader = new Symfony\Component\ClassLoader\UniversalClassLoader;
  28. $loader->registerNamespaces(array(
  29. 'Symfony' => VENDOR_PATH,
  30. 'Doctrine\\MongoDB' => VENDOR_PATH.'/doctrine-mongodb/lib',
  31. 'Doctrine\\ODM\\MongoDB' => VENDOR_PATH.'/doctrine-mongodb-odm/lib',
  32. 'Doctrine\\Common' => VENDOR_PATH.'/doctrine-common/lib',
  33. 'Doctrine\\DBAL' => VENDOR_PATH.'/doctrine-dbal/lib',
  34. 'Doctrine\\ORM' => VENDOR_PATH.'/doctrine-orm/lib',
  35. 'Gedmo\\Mapping\\Mock' => __DIR__,
  36. 'Gedmo' => __DIR__.'/../lib',
  37. 'Tool' => __DIR__.'/Gedmo',
  38. // fixture namespaces
  39. 'Translator\\Fixture' => __DIR__.'/Gedmo',
  40. 'Translatable\\Fixture' => __DIR__.'/Gedmo',
  41. 'Timestampable\\Fixture' => __DIR__.'/Gedmo',
  42. 'Tree\\Fixture' => __DIR__.'/Gedmo',
  43. 'Sluggable\\Fixture' => __DIR__.'/Gedmo',
  44. 'Sortable\\Fixture' => __DIR__.'/Gedmo',
  45. 'Mapping\\Fixture' => __DIR__.'/Gedmo',
  46. 'Loggable\\Fixture' => __DIR__.'/Gedmo',
  47. 'Wrapper\\Fixture' => __DIR__.'/Gedmo',
  48. ));
  49. $loader->register();
  50. Doctrine\Common\Annotations\AnnotationRegistry::registerFile(
  51. VENDOR_PATH.'/doctrine-orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'
  52. );
  53. Doctrine\Common\Annotations\AnnotationRegistry::registerFile(
  54. VENDOR_PATH.'/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php'
  55. );
  56. Gedmo\DoctrineExtensions::registerAnnotations();
  57. $reader = new \Doctrine\Common\Annotations\AnnotationReader();
  58. $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache());
  59. $_ENV['annotation_reader'] = $reader;