/**
  * Verify that getManager() returns a new instance after a call to resetManager().
  */
 public function test_get_manager_after_reset_should_return_new_manager()
 {
     $this->container->shouldReceive('singleton');
     $this->registry->addManager('default');
     $this->container->shouldReceive('make')->with('doctrine.managers.default')->andReturn(new stdClass(), new stdClass());
     $first = $this->registry->getManager();
     $this->container->shouldReceive('forgetInstance');
     $this->registry->resetManager();
     $second = $this->registry->getManager();
     $this->assertNotSame($first, $second);
 }
示例#2
0
 public function test_get_alias_namespace()
 {
     $this->container->shouldReceive('singleton');
     $this->registry->addManager('default');
     $em = m::mock(EntityManagerInterface::class);
     $configuration = m::mock(Configuration::class);
     $this->container->shouldReceive('make')->with('doctrine.managers.default')->andReturn($em);
     $em->shouldReceive('getConfiguration')->andReturn($configuration);
     $configuration->shouldReceive('getEntityNamespace')->with('Alias')->once()->andReturn('Namespace');
     $this->assertEquals('Namespace', $this->registry->getAliasNamespace('Alias'));
 }
示例#3
0
 /**
  * 
  *
  * @param $manager
  * @param array $settings
  * @static 
  */
 public static function addManager($manager, $settings = array())
 {
     return \LaravelDoctrine\ORM\IlluminateRegistry::addManager($manager, $settings);
 }
 /**
  * Register the manager registry
  */
 protected function registerManagerRegistry()
 {
     $this->app->singleton('registry', function ($app) {
         $registry = new IlluminateRegistry($app, $app->make(EntityManagerFactory::class));
         // Add all managers into the registry
         foreach ($app->make('config')->get('doctrine.managers', []) as $manager => $settings) {
             $registry->addManager($manager, $settings);
             $registry->addConnection($manager);
         }
         return $registry;
     });
     $this->app->alias('registry', ManagerRegistry::class);
     $this->app->alias('registry', IlluminateRegistry::class);
 }