Example #1
0
 public function test_filters_get_registerd_on_boot()
 {
     $this->registry->shouldReceive('getManagers')->andReturn(['default' => $this->em]);
     $this->em->shouldReceive('getEventManager')->once()->andReturn($this->evm);
     $this->em->shouldReceive('getConfiguration')->once()->andReturn($this->configuration);
     $this->configuration->shouldReceive('getMetadataDriverImpl')->once()->andReturn($this->driver);
     $this->driver->shouldReceive('getReader')->once()->andReturn($this->reader);
     $collection = m::mock(FilterCollection::class);
     $this->configuration->shouldReceive('addFilter')->once()->with('filter', 'FilterMock');
     $this->configuration->shouldReceive('addFilter')->once()->with('filter2', 'FilterMock');
     $this->em->shouldReceive('getFilters')->twice()->andReturn($collection);
     $collection->shouldReceive('enable')->once()->with('filter');
     $collection->shouldReceive('enable')->once()->with('filter2');
     // Register
     $this->manager->register(new ExtensionWithFiltersMock());
     $this->manager->boot();
     // Should be inside booted extensions now
     $booted = $this->manager->getBootedExtensions();
     $this->assertTrue($booted['default']['ExtensionWithFiltersMock']);
 }
 /**
  * @param \Illuminate\Http\Request $request
  * @param Closure                  $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $this->manager->boot();
     return $next($request);
 }
 /**
  * Register doctrine extensions
  */
 protected function registerExtensions()
 {
     // Bind extension manager as singleton,
     // so user can call it and add own extensions
     $this->app->singleton(ExtensionManager::class, function ($app) {
         $manager = new ExtensionManager($this->app->make(ManagerRegistry::class));
         // Register the extensions
         foreach ($this->app->make('config')->get('doctrine.extensions', []) as $extension) {
             if (!class_exists($extension)) {
                 throw new ExtensionNotFound("Extension {$extension} not found");
             }
             $manager->register($app->make($extension));
         }
         return $manager;
     });
 }