示例#1
0
 public function testLocation()
 {
     $locator = new EntityLocator($this->entityManagerDataProvider()[0][0]);
     $entities = $locator->locateEntities(__DIR__ . '/../Entities', 'Bravo3\\Orm\\Tests\\Entities');
     $this->assertTrue(count($entities) >= 29);
     $this->assertContains(IndexedEntity::class, $entities);
     $this->assertContains(SluggedArticle::class, $entities);
     $this->assertContains(BadEntity::class, $entities);
     $this->assertContains(Category::class, $entities);
     $this->assertNotContains(Enum::class, $entities);
 }
示例#2
0
 public function testPort()
 {
     $em = $this->entityManagerDataProvider()[0][0];
     $locator = new EntityLocator($this->entityManagerDataProvider()[0][0]);
     $entities = $locator->locateEntities(__DIR__ . '/../../Entities', 'Bravo3\\Orm\\Tests\\Entities');
     foreach ($this->getWriters() as $porter) {
         $porter->setInputManager($em);
         // Should NOT be in output
         $porter->compileMetadataForEntity(Category::class);
         $porter->purge();
         // Should be in output
         foreach ($entities as $class_name) {
             $porter->compileMetadataForEntity($class_name);
         }
         $porter->flush();
     }
 }
示例#3
0
文件: bootstrap.php 项目: bravo3/orm
<?php

use Bravo3\Orm\Drivers\Filesystem\FilesystemDriver;
use Bravo3\Orm\Drivers\Filesystem\Io\NativeIoDriver;
use Bravo3\Orm\Mappers\Annotation\AnnotationMapper;
use Bravo3\Orm\Mappers\Portation\MapWriterInterface;
use Bravo3\Orm\Mappers\Yaml\YamlMapWriter;
use Bravo3\Orm\Services\EntityLocator;
use Bravo3\Orm\Services\EntityManager;
use Bravo3\Properties\Conf;
use Predis\Client;
require __DIR__ . '/../vendor/autoload.php';
Conf::init(__DIR__ . '/config/', 'parameters.yml');
$redis = new Client(['host' => Conf::get('parameters.redis_host'), 'port' => Conf::get('parameters.redis_port'), 'database' => Conf::get('parameters.redis_database')]);
$redis->flushdb();
// Solely for portation (reading metadata) - will never do anything
$em = EntityManager::build(new FilesystemDriver(new NativeIoDriver('/dev/null')), new AnnotationMapper());
$locator = new EntityLocator($em);
$entities = $locator->locateEntities(__DIR__ . '/Bravo3/Orm/Tests/Entities', 'Bravo3\\Orm\\Tests\\Entities');
/** @var MapWriterInterface[] $porters */
$porters = [new YamlMapWriter(__DIR__ . '/Bravo3/Orm/Tests/Resources/mappings.yml')];
foreach ($porters as $porter) {
    $porter->setInputManager($em);
    foreach ($entities as $class_name) {
        $porter->compileMetadataForEntity($class_name);
    }
    $porter->flush();
}