本文整理匯總了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'));
}