本文整理汇总了PHP中Symfony\Component\DependencyInjection\Container::leaveScope方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::leaveScope方法的具体用法?PHP Container::leaveScope怎么用?PHP Container::leaveScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\Container
的用法示例。
在下文中一共展示了Container::leaveScope方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPathsAdded
/**
* @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');
}
示例2: testReEnteringAScope
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');
}
示例3: testIsScopeActive
/**
* @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'));
}