Beispiel #1
0
 /**
  * Creates an EntityManager for testing purposes.
  *
  * NOTE: The created EntityManager will have its dependant DBAL parts completely
  * mocked out using a DriverMock, ConnectionMock, etc. These mocks can then
  * be configured in the tests to simulate the DBAL behavior that is desired
  * for a particular test,
  *
  * @return \Doctrine\OXM\XmlEntityManager
  */
 protected function _getTestXmlEntityManager($eventManager = null, $withSharedMetadata = true)
 {
     $config = new \Doctrine\OXM\Configuration();
     if ($withSharedMetadata) {
         $config->setMetadataCacheImpl(self::getSharedMetadataCacheImpl());
     } else {
         $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     }
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(__DIR__ . '/OXM/Entities')));
     $storage = new \Doctrine\OXM\Storage\FileSystemStorage(__DIR__ . '/Workspace');
     $config->setProxyDir(__DIR__ . '/Proxies');
     $config->setProxyNamespace('Doctrine\\Tests\\Proxies');
     $eventManager = new \Doctrine\Common\EventManager();
     return \Doctrine\Tests\Mocks\XmlEntityManagerMock::create($storage, $config, $eventManager);
 }
 private static function createOxmConfiguration()
 {
     $applicationMode = "development";
     if ($applicationMode == "development") {
         $cache = new Doctrine\Common\Cache\ArrayCache();
     } else {
         $cache = new Doctrine\Common\Cache\ApcCache();
     }
     $config = new Doctrine\OXM\Configuration();
     $config->setMetadataCacheImpl($cache);
     $driverImpl = $config->newDefaultAnnotationDriver(THISPATH . '/entities');
     $config->setMetadataDriverImpl($driverImpl);
     //$config->setQueryCacheImpl($cache);
     $config->setProxyDir(THISPATH . '/proxy');
     $config->setProxyNamespace('Verify\\Proxies');
     $config->setEntityNamespaces(array('entities'));
     if ($applicationMode == "development") {
         $config->setAutoGenerateProxyClasses(true);
     } else {
         $config->setAutoGenerateProxyClasses(false);
     }
     self::$oxmConfig = $config;
 }
<?php

define('VENDOR_DIR', is_dir(__DIR__ . '/../vendor/doctrine-common') ? __DIR__ . '/../vendor' : __DIR__ . '/../lib/vendor');
require_once VENDOR_DIR . '/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
$loader = new \Doctrine\Common\ClassLoader('Doctrine\\Common', VENDOR_DIR . '/doctrine-common/lib');
$loader->register();
$loader = new \Doctrine\Common\ClassLoader('Doctrine', __DIR__ . '/../lib');
$loader->register();
$loader = new \Doctrine\Common\ClassLoader('Symfony', VENDOR_DIR);
$loader->register();
$loader = new \Doctrine\Common\ClassLoader('Documents', __DIR__);
$loader->register();
$paths = __DIR__ . '/Documents';
$config = new \Doctrine\OXM\Configuration();
$config->setProxyDir(\sys_get_temp_dir());
$config->setProxyNamespace('Doctrine\\Sandbox\\Proxies');
$metaDriver = $config->newDefaultAnnotationDriver(array($paths));
$config->setMetadataDriverImpl($metaDriver);
\Doctrine\OXM\Mapping\Driver\AnnotationDriver::registerAnnotationClasses();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
$storage = new \Doctrine\OXM\Storage\FileSystemStorage(__DIR__ . '/Workspace');
$dm = new \Doctrine\OXM\XmlEntityManager($storage, $config);
ob_start(function ($output) {
    if (PHP_SAPI != "cli") {
        return nl2br($output);
    } else {
        return $output;
    }
});