public function __construct($setConfigFiles = true)
 {
     if ($setConfigFiles) {
         $this->configFile = __DIR__ . '/../../../config.php';
         $this->localConfigFile = __DIR__ . '/../../../config.local.php';
     }
     parent::__construct();
     $isDevMode = false;
     $cache = new \Doctrine\Common\Cache\FilesystemCache(__DIR__ . '/../../tmp');
     $config = Setup::createConfiguration($isDevMode, __DIR__ . '/../../tmp', $cache);
     $config->setProxyDir(__DIR__ . '/../../tmp');
     $config->setProxyNamespace('MyProject\\Proxies');
     $config->setAutoGenerateProxyClasses(true);
     $paths = [__DIR__ . '/../Entity'];
     $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(new AnnotationReader(), $paths);
     \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');
     $config->setMetadataDriverImpl($driver);
     //$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
     $conn = ['driver' => 'mysqli', 'host' => '127.0.0.1', 'user' => $this->databaseFactory->getUserName(), 'password' => $this->databaseFactory->getPassword(), 'dbname' => $this->databaseFactory->getDatabaseName()];
     $this->entityManager = EntityManager::create($conn, $config);
     $this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     \Doctrine\DBAL\Types\Type::addType('enum', StringType::class);
     $this->entityManager->getConfiguration()->addCustomStringFunction('DATE', DateFunction::class);
     $this->user = $this->entityManager->createQueryBuilder()->select('u')->from(Sources\Tests\Entity\User::class, 'u');
 }
示例#2
0
 protected function setUp()
 {
     parent::setUp();
     $this->connection = new Database\Connection($this->baseConnection->getDsn(), $this->databaseFactory->getUserName(), $this->databaseFactory->getPassword());
     $cacheMemoryStorage = new MemoryStorage();
     $structure = new Database\Structure($this->connection, $cacheMemoryStorage);
     $conventions = new Database\Conventions\DiscoveredConventions($structure);
     $this->context = new Database\Context($this->connection, $structure, $conventions, $cacheMemoryStorage);
     $this->user = $this->context->table('users');
 }
示例#3
0
 protected function getFirstExpectedGroup()
 {
     $out = parent::getFirstExpectedGroup();
     $out['date'] = new DateTime('2016-01-01');
     return $out;
 }