public function setUp() { $config = new Configuration(); $config->setMetadataDriverImpl(AnnotationDriver::create("tests/Doctrine/Tests/OXM/Entities")); $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache()); $this->metadataFactory = new ClassMetadataFactory($config); $this->marshaller = new XmlMarshaller($this->metadataFactory); }
/** * @static * @param \Doctrine\OXM\Storage\Storage|null $storage * @param \Doctrine\OXM\Configuration|null $config * @param \Doctrine\Common\EventManager|null $eventManager * @return XmlEntityManagerMock */ public static function create(\Doctrine\OXM\Storage\Storage $storage = null, \Doctrine\OXM\Configuration $config = null, \Doctrine\Common\EventManager $eventManager = null) { if (is_null($storage)) { $storage = new \Doctrine\OXM\Storage\FileSystemStorage(__DIR__ . '/../Workspace'); } if (is_null($config)) { $config = new \Doctrine\OXM\Configuration(); $config->setMetadataDriverImpl(\Doctrine\OXM\Mapping\Driver\AnnotationDriver::create(__DIR__ . '/../OXM/Entities')); } if (is_null($eventManager)) { $eventManager = new \Doctrine\Common\EventManager(); } return new XmlEntityManagerMock($storage, $config, $eventManager); }
/** * @param $paths * @return \Doctrine\OXM\Marshaller\Marshaller */ protected function _getMarshaller($paths) { $config = new \Doctrine\OXM\Configuration(); if (empty($paths)) { $paths = "tests/Doctrine/Tests/OXM/Entities"; } if (!is_array($paths)) { $paths = array($paths); } foreach ($paths as $key => $path) { if (substr($path, 0, 1) !== '/') { $paths[$key] = __DIR__ . '/../../../' . $path; } } $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths)); \Doctrine\OXM\Mapping\Driver\AnnotationDriver::registerAnnotationClasses(); $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache()); $metadataFactory = new \Doctrine\OXM\Mapping\ClassMetadataFactory($config); return new \Doctrine\OXM\Marshaller\XmlMarshaller($metadataFactory); }
<?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; } });