Thanks so much. I was looking for this!

2011/5/18 defrag <dabrowsk...@gmail.com>

> Thank you! That solved the issue: Im pasting setUp code if anyone
> would need this:
>
> public $entityManager = null;
>     public function setUp()
>    {
>      $config = new \Doctrine\ORM\Configuration();
>      $config->setMetadataCacheImpl(new \Doctrine\Common\Cache
> \ArrayCache);
>      $config->setQueryCacheImpl(new \Doctrine\Common\Cache
> \ArrayCache);
>
>       $d = new \Doctrine\Common\Annotations\AnnotationReader();
>      $d->setAnnotationNamespaceAlias('Doctrine\\ORM\\Mapping\\',
> 'orm');
>
>      $e = new \Doctrine\ORM\Mapping\Driver\DriverChain();
>      $e->addDriver(new \Doctrine\ORM\Mapping\Driver
> \AnnotationDriver($d, array(0 => '/Applications/MAMP/htdocs/eko/trunk/
> src/Brillante/SampleBundle/Entity')), 'Brillante\\SampleBundle\
> \Entity');
>
>
>      $config->setMetadataDriverImpl($e);
>      $config->setProxyDir('/Applications/MAMP/htdocs/eko/trunk/app/
> cache/dev/doctrine/orm/Proxies');
>      $config->setProxyNamespace('Proxies');
>       $conn = array(
>        'driver' => 'pdo_sqlite',
>        'memory' => true,
>        );
>
>       $this->entityManager = \Doctrine\ORM
> \EntityManager::create($conn, $config);
>       $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this-
> >entityManager);
>
>      $schemaTool->createSchema(array(
>        $this->entityManager->getClassMetadata('Brillante\SampleBunde
> \Entity\User'),
>        $this->entityManager->getClassMetadata('Brillante\SampleBundle
> \Entity\Account')
>
>      ));
>     }
>
> On 17 Maj, 22:15, Marco Pivetta <ocram...@gmail.com> wrote:
> > You should look at
> >
> Doctrine\Common\Annotations\AnnotationReader#setAnnotationNamespaceAlias($namespace,
> > $alias)
> > That should do the job if you set $namespace = 'orm' and $alias =
> > 'Doctrine\ORM\Mapping'
> >
> > Give it a try :)
> >
> > Marco Pivetta
> > @Ocramius <http://twitter.com/Ocramius>http://marco-pivetta.com
> >
> > On 17 May 2011 12:49, defrag <dabrowsk...@gmail.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hello, im trying to get doctrine2 tests work against database, but
> > > without success. Ive tried approach with creating entity manager:
> >
> > >    class UserTest extends  \PHPUnit_Framework_TestCase {
> >
> > >         private $em = null;
> >
> > >          public function setUp()
> > >          {
> > >              $config = new \Doctrine\ORM\Configuration();
> > >              $config->setMetadataCacheImpl(new \Doctrine\Common\Cache
> > > \ArrayCache);
> > >              $config->setQueryCacheImpl(new \Doctrine\Common\Cache
> > > \ArrayCache);
> > >              $config->setProxyDir(__DIR__ . '/_files');
> > >              $config->setProxyNamespace('Proxies');
> > >              $config->setMetadataDriverImpl($config-
> > > >newDefaultAnnotationDriver());
> >
> > >              $conn = array(
> > >                  'driver' => 'pdo_sqlite',
> > >                  'memory' => true,
> > >              );
> >
> > >              #$config->setSQLLogger(new \Doctrine\DBAL\Logging
> > > \EchoSQLLogger());
> >
> > >              $this->em = \Doctrine\ORM\EntityManager::create($conn,
> > > $config);
> > >              var_Dump($this->em);
> > >              $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this-
> > > >em);
> > >              $schemaTool->createSchema(array(
> > >                  $this->em->getClassMetadata('Brillante/SampleBundle/
> > > Entity/Account'),
> >
> > >              ));
> >
> > >          }
> >
> > > And ive got error:     that given class is not a valid entity or
> > > mapped super class.
> > > Ive figured out that in setUp it creates annotation driver that
> > > required Entity to be mapped as @Entity, not as @orm:Entity. Any idea
> > > how to ovveride this?
> >
> > > --
> > > If you want to report a vulnerability issue on symfony, please send it
> to
> > > security at symfony-project.com
> >
> > > You received this message because you are subscribed to the Google
> > > Groups "symfony users" group.
> > > To post to this group, send email to symfony-users@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > symfony-users+unsubscr...@googlegroups.com
> > > For more options, visit this group at
> > >http://groups.google.com/group/symfony-users?hl=en
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to