當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。