本文整理汇总了PHP中Magento\Backend\Helper\Data::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::expects方法的具体用法?PHP Data::expects怎么用?PHP Data::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Backend\Helper\Data
的用法示例。
在下文中一共展示了Data::expects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirectSection
/**
* Redirect into response section
*
* @return void
*/
protected function redirectSection()
{
$this->actionFlag->expects($this->once())->method('get')->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED)->will($this->returnValue(true));
$this->sessionMock->expects($this->once())->method('setIsUrlNotice')->with(true);
$this->helperMock->expects($this->once())->method('getUrl')->will($this->returnValue('redirect-path'));
$this->responseMock->expects($this->once())->method('setRedirect');
}
示例2: testExecute
/**
* @param array $indexerIds
* @param \Exception $exception
* @param array $expectsExceptionValues
* @dataProvider executeDataProvider
*/
public function testExecute($indexerIds, $exception, $expectsExceptionValues)
{
$this->model = new \Magento\Indexer\Controller\Adminhtml\Indexer\MassChangelog($this->contextMock);
$this->request->expects($this->any())->method('getParam')->with('indexer_ids')->will($this->returnValue($indexerIds));
if (!is_array($indexerIds)) {
$this->messageManager->expects($this->once())->method('addError')->with(__('Please select indexers.'))->will($this->returnValue(1));
} else {
$this->objectManager->expects($this->any())->method('get')->with('Magento\\Framework\\Indexer\\IndexerRegistry')->will($this->returnValue($this->indexReg));
$indexerInterface = $this->getMockForAbstractClass('Magento\\Framework\\Indexer\\IndexerInterface', ['setScheduled'], '', false);
$this->indexReg->expects($this->any())->method('get')->with(1)->will($this->returnValue($indexerInterface));
if ($exception !== null) {
$indexerInterface->expects($this->any())->method('setScheduled')->with(true)->will($this->throwException($exception));
} else {
$indexerInterface->expects($this->any())->method('setScheduled')->with(true)->will($this->returnValue(1));
}
$this->messageManager->expects($this->any())->method('addSuccess')->will($this->returnValue(1));
if ($exception !== null) {
$this->messageManager->expects($this->exactly($expectsExceptionValues[2]))->method('addError')->with($exception->getMessage());
$this->messageManager->expects($this->exactly($expectsExceptionValues[1]))->method('addException')->with($exception, "We couldn't change indexer(s)' mode because of an error.");
}
}
$this->helper->expects($this->any())->method("getUrl")->willReturn("magento.com");
$this->response->expects($this->any())->method("setRedirect")->willReturn(1);
$this->model->executeInternal();
}
示例3: testExecute
public function testExecute()
{
$firstElement = 'firstElement';
$symbolsDataArray = [$firstElement];
$redirectUrl = 'redirectUrl';
$this->requestMock->expects($this->once())->method('getParam')->with('custom_currency_symbol')->willReturn($symbolsDataArray);
$this->helperMock->expects($this->once())->method('getUrl')->with('*');
$this->redirectMock->expects($this->once())->method('getRedirectUrl')->willReturn($redirectUrl);
$this->currencySymbolMock->expects($this->once())->method('setCurrencySymbolsData')->with($symbolsDataArray);
$this->responseMock->expects($this->once())->method('setRedirect');
$this->filterManagerMock->expects($this->once())->method('stripTags')->with($firstElement)->willReturn($firstElement);
$this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\CurrencySymbol\\Model\\System\\Currencysymbol')->willReturn($this->currencySymbolMock);
$this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\Filter\\FilterManager')->willReturn($this->filterManagerMock);
$this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('You applied the custom currency symbols.'));
$this->action->execute();
}
示例4: prepareRedirect
/**
* @param string $path
* @param array $arguments
* @param int $index
*/
protected function prepareRedirect($path, $arguments, $index)
{
$this->actionFlag->expects($this->any())->method('get')->with('', 'check_url_settings')->will($this->returnValue(true));
$this->session->expects($this->any())->method('setIsUrlNotice')->with(true);
$url = $path . '/' . (!empty($arguments) ? $arguments['shipment_id'] : '');
$this->helper->expects($this->at($index))->method('getUrl')->with($path, $arguments)->will($this->returnValue($url));
$this->response->expects($this->at($index))->method('setRedirect')->with($url);
}
示例5: testGetImageHtmlDeclaration
/**
* @param string $baseUrl
* @param string $fileName
* @param bool $isUsingStaticUrls
* @param string $expectedHtml
* @dataProvider providerGetImageHtmlDeclaration
*/
public function testGetImageHtmlDeclaration($baseUrl, $fileName, $isUsingStaticUrls, $expectedHtml)
{
$directive = '{{media url="/' . $fileName . '"}}';
$this->generalSettingsGetImageHtmlDeclaration($baseUrl, $isUsingStaticUrls);
$this->urlEncoderMock->expects($this->any())->method('encode')->with($directive)->willReturn($directive);
$this->backendDataMock->expects($this->any())->method('getUrl')->with('cms/wysiwyg/directive', ['___directive' => $directive])->willReturn($directive);
$this->assertEquals($expectedHtml, $this->imagesHelper->getImageHtmlDeclaration($fileName));
}
示例6: testExecute
/**
* @return void
*/
public function testExecute()
{
$successMessage = 'All other open sessions for this account were terminated.';
$this->sessionsManager->expects($this->once())->method('logoutOtherUserSessions');
$this->messageManager->expects($this->once())->method('addSuccess')->with($successMessage);
$this->messageManager->expects($this->never())->method('addError');
$this->messageManager->expects($this->never())->method('addException');
$this->responseMock->expects($this->once())->method('setRedirect');
$this->actionFlagMock->expects($this->once())->method('get')->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED);
$this->backendHelperMock->expects($this->once())->method('getUrl');
$this->controller->execute();
}
示例7: testResetPasswordActionSendEmail
public function testResetPasswordActionSendEmail()
{
$customerId = 1;
$email = 'test@example.com';
$websiteId = 1;
$redirectLink = 'customer/*/edit';
$this->_request->expects($this->once())->method('getParam')->with($this->equalTo('customer_id'), $this->equalTo(0))->will($this->returnValue($customerId));
$customer = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\Data\\CustomerInterface', ['getId', 'getEmail', 'getWebsiteId']);
$customer->expects($this->once())->method('getEmail')->will($this->returnValue($email));
$customer->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId));
$this->_customerRepositoryMock->expects($this->once())->method('getById')->with($customerId)->will($this->returnValue($customer));
// verify initiatePasswordReset() is called
$this->_customerAccountManagementMock->expects($this->once())->method('initiatePasswordReset')->with($email, AccountManagement::EMAIL_REMINDER, $websiteId);
// verify success message
$this->messageManager->expects($this->once())->method('addSuccess')->with($this->equalTo('Customer will receive an email with a link to reset password.'));
// verify redirect
$this->_helper->expects($this->any())->method('getUrl')->with($this->equalTo('customer/*/edit'), $this->equalTo(['id' => $customerId, '_current' => true]))->will($this->returnValue($redirectLink));
$this->resultRedirectMock->expects($this->once())->method('setPath')->with($redirectLink, ['id' => $customerId, '_current' => true]);
$this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Redirect', $this->_testedObject->execute());
}