本文整理汇总了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);
}
示例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);
}