/**
  * @covers Hearsay\RequireJSBundle\Configuration\ConfigurationBuilder::__construct
  * @covers Hearsay\RequireJSBundle\Configuration\ConfigurationBuilder::setPath
  * @covers Hearsay\RequireJSBundle\Configuration\ConfigurationBuilder::getConfiguration
  */
 public function testPathsAdded()
 {
     $mapping = $this->getMock('Hearsay\\RequireJSBundle\\Configuration\\NamespaceMappingInterface');
     $this->container->leaveScope('request');
     $this->container->setParameter('assetic.use_controller', false);
     $builder = new ConfigurationBuilder($this->container, $mapping, 'js');
     $builder->setPath('namespace', '/path/to/namespace');
     $config = $builder->getConfiguration();
     $expected = array('namespace' => '/path/to/namespace');
     $this->assertEquals($expected, $config['paths'], 'Did not find expected paths configuration');
 }
 public function testReEnteringAScope()
 {
     $event = new Event();
     $service1 = $this->getMock('Symfony\\Bundle\\FrameworkBundle\\Tests\\Service');
     $service1->expects($this->exactly(2))->method('onEvent')->with($event);
     $scope = new Scope('scope');
     $container = new Container();
     $container->addScope($scope);
     $container->enterScope('scope');
     $container->set('service.listener', $service1, 'scope');
     $dispatcher = new ContainerAwareEventDispatcher($container);
     $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
     $dispatcher->dispatch('onEvent', $event);
     $service2 = $this->getMock('Symfony\\Bundle\\FrameworkBundle\\Tests\\Service');
     $service2->expects($this->once())->method('onEvent')->with($event);
     $container->enterScope('scope');
     $container->set('service.listener', $service2, 'scope');
     $dispatcher->dispatch('onEvent', $event);
     $container->leaveScope('scope');
     $dispatcher->dispatch('onEvent');
 }
Esempio n. 3
0
 /**
  * @group legacy
  */
 public function testIsScopeActive()
 {
     $c = new Container();
     $this->assertFalse($c->isScopeActive('foo'));
     $c->addScope(new Scope('foo'));
     $this->assertFalse($c->isScopeActive('foo'));
     $c->enterScope('foo');
     $this->assertTrue($c->isScopeActive('foo'));
     $c->leaveScope('foo');
     $this->assertFalse($c->isScopeActive('foo'));
 }