当前位置: 首页>>代码示例>>PHP>>正文


PHP ContainerBuilder::expects方法代码示例

本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::expects方法的具体用法?PHP ContainerBuilder::expects怎么用?PHP ContainerBuilder::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\DependencyInjection\ContainerBuilder的用法示例。


在下文中一共展示了ContainerBuilder::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testProcessUndefinedServers

 public function testProcessUndefinedServers()
 {
     $this->containerMock->expects($this->at(0))->method('hasParameter')->with('cache.redis.servers')->will($this->returnValue(false));
     $this->containerMock->expects($this->never())->method('getParameterBag');
     $compiler = new RedisCompiler();
     $compiler->process($this->containerMock);
 }
开发者ID:hyperlator,项目名称:ElastiCacheBundle,代码行数:7,代码来源:RedisCompilerTest.php

示例2: testProcessWithoutParameter

 public function testProcessWithoutParameter()
 {
     $this->container->expects($this->once())->method('hasDefinition')->willReturn(true);
     $this->container->expects($this->never())->method('getDefinition');
     $this->container->expects($this->once())->method('hasParameter')->willReturn(false);
     $this->container->expects($this->never())->method('getParameter');
     $this->compiler->process($this->container);
 }
开发者ID:Maksold,项目名称:platform,代码行数:8,代码来源:GeneratedValueStrategyListenerPassTest.php

示例3: testServiceExistsWithTaggedServices

 public function testServiceExistsWithTaggedServices()
 {
     $this->container->expects($this->once())->method('hasDefinition')->with($this->equalTo(EntityFieldHandlerPass::HANDLER_PROCESSOR_SERVICE))->will($this->returnValue(true));
     $this->container->expects($this->once())->method('findTaggedServiceIds')->with($this->equalTo(EntityFieldHandlerPass::TAG))->will($this->returnValue(['service' => ['class' => '\\stdClass']]));
     $definition = $this->getMock('Symfony\\Component\\DependencyInjection\\Definition');
     $this->container->expects($this->once())->method('getDefinition')->with($this->equalTo(EntityFieldHandlerPass::HANDLER_PROCESSOR_SERVICE))->will($this->returnValue($definition));
     $definition->expects($this->once())->method('addMethodCall')->with($this->isType('string'), $this->isType('array'));
     $this->compilerPass->process($this->container);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:9,代码来源:InlineHandlerPassTest.php

示例4: testProcess

 /**
  * @dataProvider processDataProvider
  * @param bool $hasParameter
  * @param array $expectedParameter
  * @param array $parameterValue
  */
 public function testProcess($hasParameter, array $expectedParameter, $parameterValue)
 {
     $this->container->expects($this->once())->method('hasParameter')->willReturn($hasParameter);
     if ($hasParameter) {
         $this->container->expects($this->once())->method('getParameter')->willReturn($parameterValue);
     }
     $this->container->expects($this->once())->method('setParameter')->with($this->isType('string'), $this->equalTo($expectedParameter));
     $this->compiler->process($this->container);
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:ListenerExcludeConfigConnectionPassTest.php

示例5: testProcessNoTagged

 public function testProcessNoTagged()
 {
     $definition = $this->getMock('Symfony\\Component\\DependencyInjection\\Definition');
     $definition->expects($this->never())->method('addMethodCall');
     $this->containerBuilder->expects($this->once())->method('has')->with(OwnershipTreeProvidersPass::CHAIN_SERVICE_ID)->willReturn(true);
     $this->containerBuilder->expects($this->once())->method('getDefinition')->with(OwnershipTreeProvidersPass::CHAIN_SERVICE_ID)->willReturn($definition);
     $this->containerBuilder->expects($this->once())->method('findTaggedServiceIds')->with(OwnershipTreeProvidersPass::TAG_NAME)->willReturn([]);
     $this->compilerPass->process($this->containerBuilder);
 }
开发者ID:Maksold,项目名称:platform,代码行数:9,代码来源:OwnershipTreeProvidersPassTest.php

示例6: testServiceExistsWithTaggedServices

 public function testServiceExistsWithTaggedServices()
 {
     $this->container->expects($this->once())->method('hasDefinition')->with($this->equalTo(InlineEditColumnOptionsGuesserPass::INLINE_EDIT_COLUMN_OPTIONS_GUESSER_SERVICE))->will($this->returnValue(true));
     $this->container->expects($this->once())->method('findTaggedServiceIds')->with($this->equalTo(InlineEditColumnOptionsGuesserPass::TAG))->will($this->returnValue(['service' => ['class' => '\\stdClass']]));
     $definition = $this->getMock('Symfony\\Component\\DependencyInjection\\Definition');
     $this->container->expects($this->once())->method('getDefinition')->with($this->equalTo(InlineEditColumnOptionsGuesserPass::INLINE_EDIT_COLUMN_OPTIONS_GUESSER_SERVICE))->will($this->returnValue($definition));
     $definition->expects($this->once())->method('addMethodCall')->with($this->isType('string'), $this->isType('array'));
     $this->compilerPass->process($this->container);
 }
开发者ID:Maksold,项目名称:platform,代码行数:9,代码来源:InlineEditColumnOptionsGuesserPassTest.php

示例7: testProcess

 /**
  * @param bool $hasConnectionParameter
  * @param bool $hasExcludedParameter
  * @param mixed $connectionParameter
  * @param mixed $excludedParameter
  * @param array $tags
  *
  * @dataProvider dataProvider
  */
 public function testProcess($hasConnectionParameter, $hasExcludedParameter, $connectionParameter, $excludedParameter, array $tags = [])
 {
     $this->container->expects($this->any())->method('hasParameter')->willReturnOnConsecutiveCalls($hasConnectionParameter, $hasExcludedParameter);
     $this->container->expects($this->any())->method('getParameter')->willReturnOnConsecutiveCalls($connectionParameter, $excludedParameter);
     $this->container->expects($this->any())->method('findTaggedServiceIds')->willReturn(['id' => ['event' => ['tag1' => []]]]);
     $definition = new Definition();
     $this->container->expects($this->any())->method('getDefinition')->willReturn($definition);
     $this->compiler->process($this->container);
     $this->assertEquals($tags, $definition->getTags());
 }
开发者ID:Maksold,项目名称:platform,代码行数:19,代码来源:UpdateDoctrineEventHandlersPassTest.php

示例8: testProcessWithLazyRegistry

 public function testProcessWithLazyRegistry()
 {
     $this->container->expects($this->once())->method('findTaggedServiceIds')->with($this->identicalTo($tag = 'lug.registry'))->will($this->returnValue([$service = 'my.registry' => []]));
     $this->container->expects($this->once())->method('getDefinition')->with($this->identicalTo($service))->will($this->returnValue($definition = $this->createDefinitionMock()));
     $definition->expects($this->once())->method('getClass')->will($this->returnValue(LazyServiceRegistry::class));
     $definition->expects($this->never())->method('clearTag');
     $definition->expects($this->never())->method('removeMethodCall')->with('offsetSet');
     $this->container->expects($this->never())->method('setDefinition');
     $this->compiler->process($this->container);
 }
开发者ID:blazarecki,项目名称:lug,代码行数:10,代码来源:ConvertServiceRegistryPassTest.php

示例9: testProcessWithoutAlias

 /**
  * @expectedException
  * @expectedExceptionMessage
  */
 public function testProcessWithoutAlias()
 {
     $definition = $this->getMock('Symfony\\Component\\DependencyInjection\\Definition');
     $definition->expects($this->never())->method('addMethodCall');
     $this->container->expects($this->once())->method('has')->with($this->chainServiceId)->willReturn(true);
     $this->container->expects($this->once())->method('getDefinition')->with($this->chainServiceId)->willReturn($definition);
     $this->container->expects($this->once())->method('findTaggedServiceIds')->with($this->tagName)->willReturn(['provider1' => [['class' => 'Test\\Class1']]]);
     $this->setExpectedException('\\InvalidArgumentException', 'Tag ' . $this->tagName . ' alias is missing for provider1 service');
     $this->compilerPass->process($this->container);
 }
开发者ID:Maksold,项目名称:platform,代码行数:14,代码来源:AbstractProvidersPassTest.php

示例10: testProcess

 public function testProcess()
 {
     $registryDefinition = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Definition')->getMock();
     $registryDefinition->expects($this->at(0))->method('addMethodCall')->with($this->equalTo('addType'), $this->equalTo([new Reference('service1')]));
     $registryDefinition->expects($this->at(1))->method('addMethodCall')->with($this->equalTo('addType'), $this->equalTo([new Reference('service2')]));
     $service1Definition = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Definition')->getMock();
     $service1Definition->expects($this->once())->method('setPublic')->with(false);
     $service2Definition = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Definition')->getMock();
     $service2Definition->expects($this->once())->method('setPublic')->with(false);
     $serviceIds = ['service1' => [], 'service2' => []];
     $this->container->expects($this->once())->method('hasDefinition')->with($this->equalTo('orob2b_attribute.attribute_type.registry'))->will($this->returnValue(true));
     $this->container->expects($this->exactly(3))->method('getDefinition')->will($this->returnValueMap([['orob2b_attribute.attribute_type.registry', $registryDefinition], ['service1', $service1Definition], ['service2', $service2Definition]]));
     $this->container->expects($this->once())->method('findTaggedServiceIds')->with($this->equalTo('orob2b_attribute.attribute_type'))->will($this->returnValue($serviceIds));
     $compilerPass = new AttributeProviderPass();
     $compilerPass->process($this->container);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:16,代码来源:AttributeProviderPassTest.php

示例11: testProcess

 public function testProcess()
 {
     $that = $this;
     foreach (array_keys($this->chains) as $i => $chain_name) {
         $services = [$i + 1 => [], $i + 2 => []];
         $definition = $this->getMock('\\Symfony\\Component\\DependencyInjection\\Definition');
         $this->container->expects($this->at($i * 3))->method('has')->with($chain_name)->will($this->returnValue(true));
         $this->container->expects($this->at($i * 3 + 1))->method('findDefinition')->with($chain_name)->will($this->returnValue($definition));
         $this->container->expects($this->at($i * 3 + 2))->method('findTaggedServiceIds')->will($this->returnValue($services))->with($this->chains[$chain_name]);
         foreach (array_keys($services) as $j => $id) {
             $definition->expects($this->at($j))->method('addMethodCall')->will($this->returnCallback(function ($method, $reference) use($that, $id) {
                 $that->assertInternalType('array', $reference);
                 $that->assertInstanceOf('\\Symfony\\Component\\DependencyInjection\\Reference', $reference[0]);
                 $that->assertEquals($id, (string) $reference[0]);
             }))->with('addPlugin');
         }
     }
     $this->compiler->process($this->container);
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:19,代码来源:PluginPassTest.php

示例12: setMockContainerService

 /**
  * Sets up a mock expectation for the container get() method.
  *
  * @param string $service_name
  *   The service name to expect for the get() method.
  * @param mixed $return
  *   The value to return from the mocked container get() method.
  */
 protected function setMockContainerService($service_name, $return = NULL)
 {
     $expects = $this->container->expects($this->once())->method('get')->with($service_name);
     if (isset($return)) {
         $expects->will($this->returnValue($return));
     } else {
         $expects->will($this->returnValue(TRUE));
     }
     \Drupal::setContainer($this->container);
 }
开发者ID:dmyerson,项目名称:d8ecs,代码行数:18,代码来源:DrupalTest.php

示例13: setContainerConfig

 /**
  * Configure container mock.
  *
  * @param array $managers Tagged filter managers.
  * @param array $filters  Tagged filters.
  */
 protected function setContainerConfig($managers, $filters)
 {
     $this->container->expects($this->any())->method('findTaggedServiceIds')->with($this->anything())->will($this->returnCallback(function ($parameter) use($managers, $filters) {
         switch ($parameter) {
             case 'es.filter_manager':
                 return $managers;
             case 'ongr_filter_manager.filter':
                 return $filters;
             default:
                 return null;
         }
     }));
 }
开发者ID:vinhdrt,项目名称:FilterManagerBundle,代码行数:19,代码来源:FilterPassTest.php

示例14: testWhenManagerMappingIsEmpty

 /**
  * Check when Manager Mapping is empty.
  */
 public function testWhenManagerMappingIsEmpty()
 {
     $expectedConnections = ['default' => ['hosts' => ['127.0.0.1:9200'], 'index_name' => 'ongr-elasticsearch-bundle-test', 'settings' => ['refresh_interval' => -1, 'number_of_replicas' => 0]]];
     $expectedManagers = ['default' => ['connection' => 'default', 'debug' => true, 'readonly' => false, 'mappings' => []]];
     $kernelBundles = [];
     $this->container->expects($this->any())->method('getParameter')->with($this->anything())->will($this->returnCallback(function ($parameters) use($expectedConnections, $expectedManagers, $kernelBundles) {
         switch ($parameters) {
             case 'es.connections':
                 return $expectedConnections;
             case 'es.managers':
                 return $expectedManagers;
             case 'kernel.bundles':
                 return $expectedManagers;
             default:
                 return null;
         }
     }));
     $compilerPass = new MappingPass();
     $compilerPass->process($this->container);
 }
开发者ID:N3m1s,项目名称:ElasticsearchBundle,代码行数:23,代码来源:MappingPassTest.php

示例15: testBuild

 public function testBuild()
 {
     $this->containerMock->expects($this->once())->method('addCompilerPass')->with($this->isInstanceOf('Igniter\\ElastiCacheBundle\\DependencyInjection\\Compiler\\RedisCompiler'));
     $compiler = new IgniterElastiCacheBundle();
     $compiler->build($this->containerMock);
 }
开发者ID:hyperlator,项目名称:ElastiCacheBundle,代码行数:6,代码来源:IgniterElastiCacheBundleTest.php


注:本文中的Symfony\Component\DependencyInjection\ContainerBuilder::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。