本文整理汇总了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());
}
示例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());
}
示例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();
}