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