public function test_can_get_all_connections() { $this->container->shouldReceive('singleton')->twice(); $this->container->shouldReceive('make')->with('doctrine.connections.default')->andReturn('connection1'); $this->container->shouldReceive('make')->with('doctrine.connections.custom')->andReturn('connection2'); $this->registry->addConnection('default'); $this->registry->addConnection('custom'); $connections = $this->registry->getConnections(); $this->assertCount(2, $connections); $this->assertContains('connection1', $connections); $this->assertContains('connection2', $connections); }
/** * * * @param $connection * @static */ public static function addConnection($connection) { return \LaravelDoctrine\ORM\IlluminateRegistry::addConnection($connection); }
/** * 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); }