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


PHP Container::expects方法代码示例

本文整理汇总了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);
 }
开发者ID:Maksold,项目名称:platform,代码行数:7,代码来源:EmailVoterTest.php

示例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);
     }
 }
开发者ID:patxi1980,项目名称:FOSRestBundle,代码行数:31,代码来源:ViewResponseListenerTest.php

示例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));
 }
开发者ID:Gendoria,项目名称:param-converter-bundle,代码行数:9,代码来源:ServiceParamConverterTest.php


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