当前位置: 首页>>代码示例>>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;未经允许,请勿转载。