bootstrap.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. 'SoftDeleteable\\Fixture' => __DIR__.'/Gedmo',
  48. 'Uploadable\\Fixture' => __DIR__.'/Gedmo',
  49. 'Wrapper\\Fixture' => __DIR__.'/Gedmo',
  50. // Stubs
  51. 'Gedmo\\Uploadable\\Stub' => __DIR__,
  52. ));
  53. $loader->register();
  54. Doctrine\Common\Annotations\AnnotationRegistry::registerFile(
  55. VENDOR_PATH.'/doctrine-orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'
  56. );
  57. Doctrine\Common\Annotations\AnnotationRegistry::registerFile(
  58. VENDOR_PATH.'/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php'
  59. );
  60. Gedmo\DoctrineExtensions::registerAnnotations();
  61. $reader = new \Doctrine\Common\Annotations\AnnotationReader();
  62. $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache());
  63. $_ENV['annotation_reader'] = $reader;