本文整理汇总了PHP中Symfony\Component\DependencyInjection\Container::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::expects方法的具体用法?PHP Container::expects怎么用?PHP Container::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\Container
的用法示例。
在下文中一共展示了Container::expects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->setMethods(['isGranted'])->getMock();
$this->container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock();
$this->container->expects($this->any())->method('get')->with('oro_security.security_facade')->willReturn($this->securityFacade);
$this->emailVoter = new EmailVoter($this->container);
}
示例2: testViewWithNoCopyDefaultVars
/**
* @dataProvider getDataForDefaultVarsCopy
*/
public function testViewWithNoCopyDefaultVars($createAnnotation, $populateDefaultVars, $shouldCopy)
{
$request = new Request();
$request->attributes->set('_template_default_vars', ['customer']);
$request->attributes->set('customer', 'A person goes here');
$view = View::create();
if ($createAnnotation) {
$viewAnnotation = new ViewAnnotation([]);
$viewAnnotation->setPopulateDefaultVars($populateDefaultVars);
$request->attributes->set('_view', $viewAnnotation);
}
$event = $this->getResponseEvent($request, $view);
$this->viewHandler = new ViewHandler(['html' => true]);
$this->viewHandler->setContainer($this->container);
// This is why we avoid container dependencies!
$that = $this;
$this->container->expects($this->exactly(2))->method('get')->with($this->logicalOr('fos_rest.view_handler', 'fos_rest.templating'))->will($this->returnCallback(function ($service) use($that) {
return $service === 'fos_rest.view_handler' ? $that->viewHandler : $that->templating;
}));
$this->listener->onKernelView($event);
$data = $view->getData();
if ($shouldCopy) {
$this->assertArrayHasKey('customer', $data);
$this->assertEquals('A person goes here', $data['customer']);
} else {
$this->assertNull($data);
}
}
示例3: testApplyIncorrectType
public function testApplyIncorrectType()
{
$service = $this->getMock('stdClass', array('dummy'));
$service->expects($this->once())->method('dummy')->will($this->returnValue(1));
$this->container->expects($this->at(0))->method('get')->with('dummy')->will($this->returnValue($service));
$request = new Request(array(), array(), array('dummy' => '1'));
$config = $this->createConfiguration('NonExistentClass', 'dummyparam', array('service' => 'dummy', 'method' => 'dummy'));
$this->assertFalse($this->converter->apply($request, $config));
}