/**
  * Tests the onKernelFinishRequest method.
  */
 public function testOnKernelFinishRequest()
 {
     $this->container->addScope(new Scope(ContaoCoreBundle::SCOPE_BACKEND, 'request'));
     $this->container->enterScope(ContaoCoreBundle::SCOPE_BACKEND);
     /** @var HttpKernelInterface $kernel */
     $kernel = $this->getMockForAbstractClass('Symfony\\Component\\HttpKernel\\Kernel', ['test', false]);
     $request = new Request();
     $request->attributes->set('_scope', ContaoCoreBundle::SCOPE_BACKEND);
     $listener = new ContainerScopeListener($this->container);
     $listener->onKernelFinishRequest(new FinishRequestEvent($kernel, $request, new Response()));
     $this->assertTrue($this->container->hasScope(ContaoCoreBundle::SCOPE_BACKEND));
     $this->assertFalse($this->container->isScopeActive(ContaoCoreBundle::SCOPE_BACKEND));
 }
 public function testPlacesAutocompleteFormType()
 {
     $this->loadConfiguration($this->container, 'empty');
     $this->container->compile();
     $this->container->enterScope('request');
     $this->assertInstanceOf('Ivory\\GoogleMapBundle\\Form\\Type\\PlacesAutocompleteType', $this->container->get('ivory_google_map.places_autocomplete.form.type'));
     $this->container->leaveScope('request');
 }
 /**
  * @dataProvider getDebugModes
  */
 public function testBaseSetup($debug)
 {
     $this->container->setParameter('kernel.debug', $debug);
     $this->container->enterScope('request');
     $this->container->set('request', Request::create('/'));
     $this->container->set('kernel', $this->kernel);
     $extension = new PlatinumPixsGoogleClosureLibraryExtension();
     $extension->load(array('platinum_pixs_google_closure_library' => array('outputMode' => 'compiled', 'compilerFlags' => array('--compilation_level=ADVANCED_OPTIMIZATIONS', "--define='somevariableinside=somevalue'"), 'externs' => array("src/PlatinumPixs/TestBundle/Resources/javascript/loggly-externs.js"), 'root' => array("src/PlatinumPixs/TestBundle/Resources/javascript"))), $this->container);
     $errors = array();
     foreach ($this->container->getServiceIds() as $id) {
         try {
             $this->container->get($id);
         } catch (\Exception $e) {
             print $e->getMessage();
             $errors[$id] = $e->getMessage();
         }
     }
     self::assertEquals(array(), $errors, '');
 }
Example #4
0
 protected function createContainerMock($render)
 {
     $templatingMock = $this->getMockBuilder('Symfony\\Bundle\\TwigBundle\\TwigEngine')->disableOriginalConstructor()->getMock();
     $templatingMock->expects($this->exactly($render))->method('render');
     $container = new ContainerBuilder();
     $container->set('templating', $templatingMock);
     $container->addScope(new Scope('request'));
     $container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
     $container->enterScope('request');
     return $container;
 }
 protected function createContainerMock()
 {
     $container = new ContainerBuilder();
     $container->addScope(new Scope('request'));
     $container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
     $container->enterScope('request');
     $container->set('templating', $this->createTemplatingMock());
     $container->set('router', $this->createRouterMock());
     $container->setParameter('thrace_media.jwplayer.options', array('key' => '123', 'html5player' => 'path_to_file', 'flashplayer' => 'path_to_file'));
     return $container;
 }
 public function testSynchronizedServiceWithScopes()
 {
     $container = new ContainerBuilder();
     $container->addScope(new Scope('foo'));
     $container->register('baz', 'BazClass')->setSynthetic(true)->setSynchronized(true)->setScope('foo');
     $container->register('bar', 'BarClass')->addMethodCall('setBaz', array(new Reference('baz', ContainerInterface::NULL_ON_INVALID_REFERENCE, false)));
     $container->compile();
     $container->enterScope('foo');
     $container->set('baz', $outerBaz = new \BazClass(), 'foo');
     $this->assertSame($outerBaz, $container->get('bar')->getBaz());
     $container->enterScope('foo');
     $container->set('baz', $innerBaz = new \BazClass(), 'foo');
     $this->assertSame($innerBaz, $container->get('bar')->getBaz());
     $container->leaveScope('foo');
     $this->assertNotSame($innerBaz, $container->get('bar')->getBaz());
     $this->assertSame($outerBaz, $container->get('bar')->getBaz());
     $container->leaveScope('foo');
 }
 public function enterScope($name)
 {
     return $this->delegate->enterScope($name);
 }