Пример #1
0
 /**
  * @group DDC-268
  */
 public function testColumnWithMissingTypeDefaultsToString()
 {
     $cm = new ClassMetadata('Doctrine\\ODM\\MongoDB\\Tests\\Mapping\\ColumnWithoutType');
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $annotationDriver = new \Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver($reader);
     $annotationDriver->loadMetadataForClass('Doctrine\\ODM\\MongoDB\\Tests\\Mapping\\InvalidColumn', $cm);
     $this->assertEquals('id', $cm->fieldMappings['id']['type']);
 }
 public function testHasGetMetadata_NamespaceSeperatorIsNotNormalized()
 {
     require_once __DIR__ . "/Documents/GlobalNamespaceDocument.php";
     $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
     $reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
     $metadataDriver = new \Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver($reader);
     $metadataDriver->addPaths(array(__DIR__ . '/../../Documents/'));
     $documentManager = $this->_createDocumentManager($metadataDriver);
     $mf = $documentManager->getMetadataFactory();
     $m1 = $mf->getMetadataFor("DoctrineGlobal_Article");
     $h1 = $mf->hasMetadataFor("DoctrineGlobal_Article");
     $h2 = $mf->hasMetadataFor("\\DoctrineGlobal_Article");
     $m2 = $mf->getMetadataFor("\\DoctrineGlobal_Article");
     $this->assertNotSame($m1, $m2);
     $this->assertFalse($h2);
     $this->assertTrue($h1);
 }
Пример #3
0
$app['autoloader']->registerPrefixes(array('Twig_Extensions_' => __DIR__ . '/../vendor/Twig-extensions/lib'));
use Silex\Extension\SymfonyBridgesExtension;
use Silex\Extension\UrlGeneratorExtension;
use Silex\Extension\TwigExtension;
use Silex\Extension\DoctrineMongoDBExtension;
use Silex\Extension\FormExtension;
use Silex\Extension\TranslationExtension;
use Culin\Twig\Extension\CulinExtension;
$app->register(new SymfonyBridgesExtension());
$app->register(new UrlGeneratorExtension());
$app->register(new FormExtension());
$app->register(new TranslationExtension(), array('translator.messages' => array()));
$app->register(new TwigExtension(), array('twig.path' => array(__DIR__ . '/templates', __DIR__ . '/../vendor/Symfony/Bridge/Twig/Resources/views/Form'), 'twig.class_path' => __DIR__ . '/../vendor/silex/vendor/twig/lib'));
$app->register(new DoctrineMongoDBExtension(), array('doctrine.odm.mongodb.connection_options' => array('database' => 'springbok-silex', 'host' => 'localhost'), 'doctrine.odm.mongodb.documents' => array(array('type' => 'annotation', 'path' => __DIR__ . '/Document', 'namespace' => 'Document')), 'doctrine.odm.mongodb.metadata_cache' => 'array', 'doctrine.common.class_path' => __DIR__ . '/../vendor/mongodb-odm/lib/vendor/doctrine-common/lib', 'doctrine.mongodb.class_path' => __DIR__ . '/../vendor/mongodb-odm/lib/vendor/doctrine-mongodb/lib', 'doctrine.odm.mongodb.class_path' => __DIR__ . '/../vendor/mongodb-odm/lib'));
$app['doctrine.odm.mongodb.hydrators_dir'] = __DIR__ . '/../cache/doctrine/hydrators';
Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::registerAnnotationClasses();
require_once __DIR__ . '/config.php';
if (!is_dir($app['doctrine.odm.mongodb.hydrators_dir'])) {
    mkdir($app['doctrine.odm.mongodb.hydrators_dir'], 0777, true);
}
$app->before(function () use($app) {
    if (!isset($app['culin.entity'])) {
        throw new \RuntimeException('Configuration entry "culin.entity" is not set');
    }
    $app['repository'] = $app['doctrine.odm.mongodb.dm']->getRepository($app['culin.entity']);
    $app['query_builder'] = $app->share(function ($app) {
        return $app['doctrine.odm.mongodb.dm']->createQueryBuilder($app['culin.entity']);
    });
    $app['form'] = $app->share(function ($app) {
        return function ($entity = null) use($app) {
            return $app['form.factory']->create(new $app['culin.form'](), $entity);
 public function testLoadPrefixedMetadata()
 {
     $metadata = $this->generateBookDocumentFixture();
     $book = $this->newInstance($metadata);
     $cm = new \Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo($metadata->name);
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $driver = new \Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver($reader);
     $driver->loadMetadataForClass($cm->name, $cm);
     $this->assertEquals($cm->getCollection(), $metadata->getCollection());
     $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks);
     $this->assertEquals($cm->identifier, $metadata->identifier);
     $this->assertEquals($cm->idGenerator, $metadata->idGenerator);
     $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName);
 }