本文整理汇总了PHP中Magento\Framework\App\RequestInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::expects方法的具体用法?PHP RequestInterface::expects怎么用?PHP RequestInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDisplay
public function testDisplay()
{
$this->markTestSkipped('Remove it when task(MAGETWO-33495) will be fixed');
$this->_response->expects($this->atLeastOnce())->method('sendHeaders');
$this->_request->expects($this->atLeastOnce())->method('getHeader');
$stat = (include __DIR__ . '/_files/timers.php');
$this->_output->display($stat);
$actualHeaders = $this->_response->getHeaders();
$this->assertNotEmpty($actualHeaders);
$actualProtocol = false;
$actualProfilerData = false;
foreach ($actualHeaders as $oneHeader) {
$headerName = $oneHeader->getFieldName();
$headerValue = $oneHeader->getFieldValue();
if (!$actualProtocol && $headerName == 'X-Wf-Protocol-1') {
$actualProtocol = $headerValue;
}
if (!$actualProfilerData && $headerName == 'X-Wf-1-1-1-1') {
$actualProfilerData = $headerValue;
}
}
$this->assertNotEmpty($actualProtocol, 'Cannot get protocol header');
$this->assertNotEmpty($actualProfilerData, 'Cannot get profiler header');
$this->assertContains('Protocol/JsonStream', $actualProtocol);
$this->assertRegExp('/"Type":"TABLE","Label":"Code Profiler \\(Memory usage: real - \\d+, emalloc - \\d+\\)"/', $actualProfilerData);
$this->assertContains('[' . '["Timer Id","Time","Avg","Cnt","Emalloc","RealMem"],' . '["root","0.080000","0.080000","1","1,000","50,000"],' . '[". init","0.040000","0.040000","1","200","2,500"],' . '[". . init_store","0.020000","0.010000","2","100","2,000"],' . '["system","0.030000","0.015000","2","400","20,000"]' . ']', $actualProfilerData);
}
示例2: testGetCollection
public function testGetCollection()
{
$this->collectionMock->expects($this->once())->method('addAttributeToFilter');
$this->productLinkRepositoryMock->expects($this->once())->method('getList')->willReturn([]);
$this->requestMock->expects($this->exactly(2))->method('getParam')->willReturn(1);
$this->assertInstanceOf(Collection::class, $this->getModel()->getCollection());
}
示例3: testExecute
public function testExecute()
{
$this->request->expects($this->once())
->method('isPost')
->willReturn(true);
$this->request->expects($this->once())
->method('getParam')
->with('files')
->willReturn('{"files":"file"}');
$jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false);
$jsonData->expects($this->once())
->method('jsonDecode')
->with('{"files":"file"}')
->willReturn(['files' => 'file']);
$this->objectManager->expects($this->at(0))
->method('get')
->with('Magento\Framework\Json\Helper\Data')
->willReturn($jsonData);
$this->objectManager->expects($this->at(1))
->method('get')
->with('Magento\Theme\Model\Wysiwyg\Storage')
->willReturn($this->storage);
$this->storage->expects($this->once())
->method('deleteFile')
->with('file');
$this->controller->executeInternal();
}
示例4: testGetAction
/**
* @param bool $isSecure
* @param string $actionUrl
* @param int $productId
* @dataProvider getActionDataProvider
*/
public function testGetAction($isSecure, $actionUrl, $productId)
{
$this->urlBuilder->expects($this->any())->method('getUrl')->with('review/product/post', ['_secure' => $isSecure, 'id' => $productId])->willReturn($actionUrl . '/id/' . $productId);
$this->requestMock->expects($this->any())->method('getParam')->with('id', false)->willReturn($productId);
$this->requestMock->expects($this->any())->method('isSecure')->willReturn($isSecure);
$this->assertEquals($actionUrl . '/id/' . $productId, $this->object->getAction());
}
示例5: setUp
protected function setUp()
{
$this->_session = $this->getMock('Magento\\Customer\\Model\\Session', [], [], '', false);
$this->_agreement = $this->getMock('Magento\\Paypal\\Model\\Billing\\Agreement', ['load', 'getId', 'getCustomerId', 'getReferenceId', 'canCancel', 'cancel', '__wakeup'], [], '', false);
$this->_agreement->expects($this->once())->method('load')->with(15)->will($this->returnSelf());
$this->_agreement->expects($this->once())->method('getId')->will($this->returnValue(15));
$this->_agreement->expects($this->once())->method('getCustomerId')->will($this->returnValue(871));
$this->_objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
$this->_objectManager->expects($this->atLeastOnce())->method('get')->will($this->returnValueMap([['Magento\\Customer\\Model\\Session', $this->_session]]));
$this->_objectManager->expects($this->once())->method('create')->with('Magento\\Paypal\\Model\\Billing\\Agreement')->will($this->returnValue($this->_agreement));
$this->_request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
$this->_request->expects($this->once())->method('getParam')->with('agreement')->will($this->returnValue(15));
$response = $this->getMock('Magento\\Framework\\App\\ResponseInterface');
$redirect = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface');
$this->_messageManager = $this->getMock('Magento\\Framework\\Message\\ManagerInterface');
$context = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
$context->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->_objectManager));
$context->expects($this->any())->method('getRequest')->will($this->returnValue($this->_request));
$context->expects($this->any())->method('getResponse')->will($this->returnValue($response));
$context->expects($this->any())->method('getRedirect')->will($this->returnValue($redirect));
$context->expects($this->any())->method('getMessageManager')->will($this->returnValue($this->_messageManager));
$this->_registry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
$title = $this->getMock('Magento\\Framework\\App\\Action\\Title', [], [], '', false);
$this->_controller = new \Magento\Paypal\Controller\Billing\Agreement\Cancel($context, $this->_registry, $title);
}
示例6: setUp
protected function setUp()
{
$this->requestMock = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getBasePath', 'isSecure', 'getHttpHost'], [], '', false, false);
$this->requestMock->expects($this->atLeastOnce())->method('getBasePath')->will($this->returnValue('/'));
$this->requestMock->expects($this->atLeastOnce())->method('getHttpHost')->will($this->returnValue('init.host'));
$this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
}
示例7: testExecuteEmptyQuery
public function testExecuteEmptyQuery()
{
$searchString = "";
$this->request->expects($this->once())->method('getParam')->with('q')->will($this->returnValue($searchString));
$this->url->expects($this->once())->method('getBaseUrl');
$this->response->expects($this->once())->method('setRedirect');
$this->controller->execute();
}
示例8: testGetData
public function testGetData()
{
$expected = ['totalRecords' => null, 'items' => []];
$this->collectionMock->expects($this->once())->method('addEntityFilter')->willReturnSelf();
$this->collectionMock->expects($this->once())->method('addStoreData')->willReturnSelf();
$this->requestMock->expects($this->once())->method('getParam')->with('current_product_id', 0)->willReturn(1);
$this->assertSame($expected, $this->model->getData());
}
示例9: testRoute
/**
* @param string $route
* @param string $path
* @param array|bool $params
* @return void
* @dataProvider dataProviderRoutes
*/
public function testRoute($route, $path, $params)
{
/** @var Route $model */
$model = $this->objectManager->getObject('Magento\\Webapi\\Controller\\Rest\\Router\\Route', ['route' => $route]);
$this->request->expects($this->once())->method('getPathInfo')->willReturn($path);
$match = $model->match($this->request);
$this->assertEquals($params, $match);
}
示例10: testDeleteActionNoId
public function testDeleteActionNoId()
{
$this->requestMock->expects($this->once())->method('getParam')->willReturn(null);
$this->messageManagerMock->expects($this->once())->method('addError')->with(__('We can\'t find a synonym group to delete.'));
$this->messageManagerMock->expects($this->never())->method('addSuccess');
$this->resultRedirectMock->expects($this->once())->method('setPath')->with('*/*/')->willReturnSelf();
$this->assertSame($this->resultRedirectMock, $this->deleteController->execute());
}
示例11: testExecuteWithoutData
public function testExecuteWithoutData()
{
$this->request->expects($this->at(0))->method('getParam')->with('isAjax')->willReturn(true);
$this->request->expects($this->at(1))->method('getParam')->with('items', [])->willReturn([]);
$this->jsonFactory->expects($this->once())->method('create')->willReturn($this->resultJson);
$this->resultJson->expects($this->once())->method('setData')->with(['messages' => ['Please correct the data sent.'], 'error' => true])->willReturnSelf();
$this->controller->execute();
}
示例12: testRequestAction
/**
* Test the basic Request action.
*/
public function testRequestAction()
{
$this->request->expects($this->any())->method('getMethod')->willReturn('GET');
$this->helperMock->expects($this->once())->method('getRequestUrl');
$this->helperMock->expects($this->once())->method('prepareRequest');
$this->frameworkOauthSvcMock->expects($this->once())->method('getRequestToken')->willReturn(['response']);
$this->response->expects($this->once())->method('setBody');
$this->requestAction->execute();
}
示例13: testExecute
/**
* Test execute()
*/
public function testExecute()
{
$this->request->expects($this->any())->method('getParam')->will($this->returnValueMap(['remote_image' => 'https://pp.vk.me/c304605/v304605289/3ff9/s4rpaW_TZ6A.jpg']));
$readInterface = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface', [], [], '', false);
$this->filesystemMock->expects($this->any())->method('getDirectoryRead')->willReturn($readInterface);
$readInterface->expects($this->any())->method('getAbsolutePath')->willReturn('/var/www/application/sample.jpg');
$this->abstractAdapter->expects($this->any())->method('validateUploadFile')->willReturn('true');
$this->image->execute();
}
示例14: testIndexActionException
public function testIndexActionException()
{
$this->request->expects($this->once())->method('isPost')->will($this->returnValue(true));
$exception = new \Exception();
$this->request->expects($this->once())->method('getPostValue')->will($this->throwException($exception));
$this->logger->expects($this->once())->method('critical')->with($this->identicalTo($exception));
$this->response->expects($this->once())->method('setHttpResponseCode')->with(500);
$this->model->executeInternal();
}
示例15: testExecuteEmptyQuery
public function testExecuteEmptyQuery()
{
$url = 'some url';
$searchString = '';
$this->request->expects($this->once())->method('getParam')->with('q')->will($this->returnValue($searchString));
$this->url->expects($this->once())->method('getBaseUrl')->willReturn($url);
$this->resultRedirectMock->expects($this->once())->method('setUrl')->with($url)->willReturnSelf();
$this->assertSame($this->resultRedirectMock, $this->controller->execute());
}