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


PHP Definition::expects方法代码示例

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


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

示例1: testConfigure

 public function testConfigure()
 {
     $config = ['type' => 'custom_provider', 'custom_provider' => ['type' => 'igniter.elasticache', 'options' => ['namespace' => 'foo']]];
     $this->definitionMock->expects($this->once())->method('addMethodCall')->with('setNamespace', ['foo']);
     $definition = new RedisCacheDefinition('igniter.elasticache.rediscache');
     $definition->configure('foo.service', $config, $this->definitionMock, $this->containerMock);
 }
开发者ID:hyperlator,项目名称:ElastiCacheBundle,代码行数:7,代码来源:RedisCacheDefinitionTest.php

示例2: testProcess

 public function testProcess()
 {
     $servers = [['host' => '127.0.0.1', 'port' => 6379], ['host' => 'localhost', 'port' => 6380, 'master' => true]];
     $this->containerMock->expects($this->at(0))->method('hasParameter')->with('cache.redis.servers')->will($this->returnValue(true));
     $this->containerMock->expects($this->at(1))->method('getDefinition')->with('igniter.elasticache.rediscache')->will($this->returnValue($this->definitionMock));
     $this->containerMock->expects($this->at(2))->method('getParameterBag')->will($this->returnValue($this->paramterBagMock));
     $this->containerMock->expects($this->at(3))->method('getParameter')->with('igniter.elasticache.redis_class')->will($this->returnValue('Redis'));
     $this->containerMock->expects($this->at(4))->method('getParameter')->with('cache.redis.servers')->will($this->returnValue($servers));
     // look up redis class param
     $this->paramterBagMock->expects($this->at(0))->method('resolveValue')->will($this->returnValue('Redis'));
     // look up servers param
     $this->paramterBagMock->expects($this->at(1))->method('resolveValue')->will($this->returnValue($servers));
     // setMaster and addSlave calls
     $this->definitionMock->expects($this->at(0))->method('addMethodCall')->with('addSlave', $this->callback(function ($subject) {
         // verify the subject is an array of 1 Defintion class
         if (count($subject) != 1 && !is_a($subject[0], 'Symfony\\Component\\DependencyInjection\\Definition')) {
             return false;
         }
         /** @var $definition \Symfony\Component\DependencyInjection\Definition */
         $definition = $subject[0];
         // verify the connect call
         if ($definition->getMethodCalls() !== [['connect', ['127.0.0.1', 6379]]]) {
             return false;
         }
         return true;
     }));
     $this->definitionMock->expects($this->at(1))->method('addMethodCall')->with('setMaster', $this->callback(function ($subject) {
         // verify the subject is an array of 1 Defintion class
         if (count($subject) != 1 && !is_a($subject[0], 'Symfony\\Component\\DependencyInjection\\Definition')) {
             return false;
         }
         /** @var $definition \Symfony\Component\DependencyInjection\Definition */
         $definition = $subject[0];
         // verify the connect call
         if ($definition->getMethodCalls() !== [['connect', ['localhost', 6380]]]) {
             return false;
         }
         return true;
     }));
     $compiler = new RedisCompiler();
     $compiler->process($this->containerMock);
 }
开发者ID:hyperlator,项目名称:ElastiCacheBundle,代码行数:42,代码来源:RedisCompilerTest.php


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