當前位置: 首頁>>代碼示例>>PHP>>正文


PHP stdClass::expects方法代碼示例

本文整理匯總了PHP中stdClass::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP stdClass::expects方法的具體用法?PHP stdClass::expects怎麽用?PHP stdClass::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在stdClass的用法示例。


在下文中一共展示了stdClass::expects方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testProcessRequestTrue

 public function testProcessRequestTrue()
 {
     $response = new Zend_Controller_Response_Http();
     $response->setBody('Initial response body.');
     $this->_requestProcessor->expects($this->any())->method('extractContent')->will($this->returnValue('Additional response text.'));
     $this->assertTrue($this->_model->processRequest($response));
     $this->assertEquals('Initial response body.Additional response text.', $response->getBody());
 }
開發者ID:nemphys,項目名稱:magento2,代碼行數:8,代碼來源:CacheTest.php

示例2: testInSecureRequestOverSecureRoute

 /**
  * Test insecure request for a secure route
  */
 public function testInSecureRequestOverSecureRoute()
 {
     $this->_serviceMock->expects($this->any())->method(self::SERVICE_METHOD)->will($this->returnValue([]));
     $this->_routeMock->expects($this->any())->method('isSecure')->will($this->returnValue(true));
     $this->_routeMock->expects($this->any())->method('getAclResources')->will($this->returnValue(['1']));
     $this->_requestMock->expects($this->any())->method('isSecure')->will($this->returnValue(false));
     $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
     // Override default prepareResponse. It should never be called in this case
     $this->_responseMock->expects($this->never())->method('prepareResponse');
     $this->_restController->dispatch($this->_requestMock);
     $this->assertTrue($this->_responseMock->isException());
     $exceptionArray = $this->_responseMock->getException();
     $this->assertEquals('Operation allowed only in HTTPS', $exceptionArray[0]->getMessage());
     $this->assertEquals(\Magento\Framework\Webapi\Exception::HTTP_BAD_REQUEST, $exceptionArray[0]->getHttpCode());
 }
開發者ID:rafaelstz,項目名稱:magento2,代碼行數:18,代碼來源:RestTest.php

示例3: setUp

 protected function setUp()
 {
     $this->deploymentConfigMock = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false, false);
     $this->_requestMock = $this->getMockBuilder('Magento\\Framework\\Webapi\\Rest\\Request')->setMethods(['isSecure', 'getRequestData', 'getParams', 'getParam', 'getRequestedServices', 'getPathInfo', 'getHttpHost', 'getMethod'])->disableOriginalConstructor()->getMock();
     $this->_requestMock->expects($this->any())->method('getHttpHost')->willReturn('testHostName.com');
     $this->_responseMock = $this->getMockBuilder('Magento\\Framework\\Webapi\\Rest\\Response')->setMethods(['sendResponse', 'prepareResponse', 'setHeader'])->disableOriginalConstructor()->getMock();
     $routerMock = $this->getMockBuilder('Magento\\Webapi\\Controller\\Rest\\Router')->setMethods(['match'])->disableOriginalConstructor()->getMock();
     $this->_routeMock = $this->getMockBuilder('Magento\\Webapi\\Controller\\Rest\\Router\\Route')->setMethods(['isSecure', 'getServiceMethod', 'getServiceClass', 'getAclResources', 'getParameters'])->disableOriginalConstructor()->getMock();
     $objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->_serviceMock = $this->getMockBuilder(self::SERVICE_ID)->setMethods([self::SERVICE_METHOD])->disableOriginalConstructor()->getMock();
     $this->_oauthServiceMock = $this->getMockBuilder('\\Magento\\Framework\\Oauth\\OauthInterface')->setMethods(['validateAccessTokenRequest'])->getMockForAbstractClass();
     $this->_authorizationMock = $this->getMockBuilder('Magento\\Framework\\Webapi\\Authorization')->disableOriginalConstructor()->getMock();
     $paramsOverriderMock = $this->getMockBuilder('Magento\\Webapi\\Controller\\Rest\\ParamsOverrider')->setMethods(['overrideParams'])->disableOriginalConstructor()->getMock();
     $dataObjectProcessorMock = $this->getMockBuilder('Magento\\Framework\\Reflection\\DataObjectProcessor')->disableOriginalConstructor()->setMethods(['getMethodReturnType'])->getMockForAbstractClass();
     $this->swaggerGeneratorMock = $this->getMockBuilder('Magento\\Webapi\\Model\\Rest\\Swagger\\Generator')->disableOriginalConstructor()->setMethods(['generate', 'getListOfServices'])->getMockForAbstractClass();
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->disableOriginalConstructor()->getMock();
     $errorProcessorMock = $this->getMock('Magento\\Framework\\Webapi\\ErrorProcessor', [], [], '', false);
     $errorProcessorMock->expects($this->any())->method('maskException')->will($this->returnArgument(0));
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->serviceInputProcessorMock = $this->getMockBuilder('\\Magento\\Framework\\Webapi\\ServiceInputProcessor')->disableOriginalConstructor()->setMethods(['process'])->getMock();
     $areaListMock = $this->getMock('\\Magento\\Framework\\App\\AreaList', [], [], '', false);
     $areaMock = $this->getMock('Magento\\Framework\\App\\AreaInterface');
     $areaListMock->expects($this->any())->method('getArea')->will($this->returnValue($areaMock));
     $this->storeMock = $this->getMock('\\Magento\\Store\\Api\\Data\\StoreInterface');
     $this->storeManagerMock = $this->getMock('\\Magento\\Store\\Model\\StoreManagerInterface');
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     /** Init SUT. */
     $this->_restController = $objectManager->getObject('Magento\\Webapi\\Controller\\Rest', ['request' => $this->_requestMock, 'response' => $this->_responseMock, 'router' => $routerMock, 'objectManager' => $objectManagerMock, 'layout' => $layoutMock, 'oauthService' => $this->_oauthServiceMock, 'authorization' => $this->_authorizationMock, 'serviceInputProcessor' => $this->serviceInputProcessorMock, 'errorProcessor' => $errorProcessorMock, 'areaList' => $areaListMock, 'paramsOverrider' => $paramsOverriderMock, 'dataObjectProcessor' => $dataObjectProcessorMock, 'swaggerGenerator' => $this->swaggerGeneratorMock, 'storeManager' => $this->storeManagerMock]);
     $this->_restController->setDeploymentConfig($this->deploymentConfigMock);
     // Set default expectations used by all tests
     $this->_routeMock->expects($this->any())->method('getServiceClass')->will($this->returnValue(self::SERVICE_ID));
     $this->_routeMock->expects($this->any())->method('getServiceMethod')->will($this->returnValue(self::SERVICE_METHOD));
     $routerMock->expects($this->any())->method('match')->will($this->returnValue($this->_routeMock));
     $objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($this->_serviceMock));
     $this->_responseMock->expects($this->any())->method('prepareResponse')->will($this->returnValue([]));
     $this->_serviceMock->expects($this->any())->method(self::SERVICE_METHOD)->will($this->returnValue(null));
     $dataObjectProcessorMock->expects($this->any())->method('getMethodReturnType')->with(self::SERVICE_ID, self::SERVICE_METHOD)->will($this->returnValue('null'));
     $paramsOverriderMock->expects($this->any())->method('overrideParams')->will($this->returnValue([]));
     parent::setUp();
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:40,代碼來源:RestTest.php


注:本文中的stdClass::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。