本文整理汇总了PHP中Magento\Framework\UrlInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlInterface::expects方法的具体用法?PHP UrlInterface::expects怎么用?PHP UrlInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\UrlInterface
的用法示例。
在下文中一共展示了UrlInterface::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: testGetRssData
public function testGetRssData()
{
$rssData = ['title' => 'Pending product review(s)', 'description' => 'Pending product review(s)', 'link' => 'http://rss.magento.com', 'charset' => 'UTF-8', 'entries' => ['title' => 'Product: "Product Name" reviewed by: Product Nick', 'link' => 'http://product.magento.com', 'description' => ['rss_url' => 'http://rss.magento.com', 'name' => 'Product Name', 'summary' => 'Product Title', 'review' => 'Product Detail', 'store' => 'Store Name']]];
$rssUrl = 'http://rss.magento.com';
$productModel = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product', ['getStoreId', 'getId', 'getReviewId', 'getName', 'getDetail', 'getTitle', 'getNickname', 'getProductUrl'], [], '', false);
$storeModel = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
$this->storeManagerInterface->expects($this->once())->method('getStore')->will($this->returnValue($storeModel));
$storeModel->expects($this->once())->method('getName')->will($this->returnValue($rssData['entries']['description']['store']));
$this->urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue($rssUrl));
$this->urlBuilder->expects($this->once())->method('setScope')->will($this->returnSelf());
$productModel->expects($this->any())->method('getStoreId')->will($this->returnValue(1));
$productModel->expects($this->any())->method('getId')->will($this->returnValue(1));
$productModel->expects($this->once())->method('getReviewId')->will($this->returnValue(1));
$productModel->expects($this->any())->method('getNickName')->will($this->returnValue('Product Nick'));
$productModel->expects($this->any())->method('getName')->will($this->returnValue($rssData['entries']['description']['name']));
$productModel->expects($this->once())->method('getDetail')->will($this->returnValue($rssData['entries']['description']['review']));
$productModel->expects($this->once())->method('getTitle')->will($this->returnValue($rssData['entries']['description']['summary']));
$productModel->expects($this->any())->method('getProductUrl')->will($this->returnValue('http://product.magento.com'));
$this->rss->expects($this->once())->method('getProductCollection')->will($this->returnValue([$productModel]));
$data = $this->block->getRssData();
$this->assertEquals($rssData['title'], $data['title']);
$this->assertEquals($rssData['description'], $data['description']);
$this->assertEquals($rssData['link'], $data['link']);
$this->assertEquals($rssData['charset'], $data['charset']);
$this->assertEquals($rssData['entries']['title'], $data['entries'][0]['title']);
$this->assertEquals($rssData['entries']['link'], $data['entries'][0]['link']);
$this->assertContains($rssData['entries']['description']['rss_url'], $data['entries'][0]['description']);
$this->assertContains($rssData['entries']['description']['name'], $data['entries'][0]['description']);
$this->assertContains($rssData['entries']['description']['summary'], $data['entries'][0]['description']);
$this->assertContains($rssData['entries']['description']['review'], $data['entries'][0]['description']);
$this->assertContains($rssData['entries']['description']['store'], $data['entries'][0]['description']);
}
示例3: testGetUrl
public function testGetUrl()
{
$queryParams = ['queryParamsArray'];
$url = 'sampleUrl';
$this->urlBuilder->expects($this->once())->method('getUrl')->with('sampleservicecontractnew/feed/view', $queryParams)->willReturn($url);
$this->assertEquals($url, $this->target->getUrl($queryParams));
}
示例4: testCheckUpdate
/**
* @dataProvider checkUpdateDataProvider
* @param bool $callInbox
* @param string $curlRequest
*/
public function testCheckUpdate($callInbox, $curlRequest)
{
$mockName = 'Test Product Name';
$mockVersion = '0.0.0';
$mockEdition = 'Test Edition';
$mockUrl = 'http://test-url';
$this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
$this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
$this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
$this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
$configValues = ['timeout' => 2, 'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')', 'referer' => $mockUrl];
$lastUpdate = 0;
$this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
$this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
$this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
$this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
$this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
$this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
$this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
$this->deploymentConfig->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
if ($callInbox) {
$this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
$this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
} else {
$this->inboxFactory->expects($this->never())->method('create');
$this->inboxModel->expects($this->never())->method('parse');
}
$this->feed->checkUpdate();
}
示例5: testGetCurrentSecureUrl
public function testGetCurrentSecureUrl()
{
$request = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface', [], '', false, true, true, ['getPathInfo']);
$request->expects($this->once())->method('getPathInfo')->willReturn('/info');
$this->url->expects($this->once())->method('getBaseUrl')->with('link', true)->willReturn('localhost/');
$this->assertEquals('localhost/info', $this->adminPathConfig->getCurrentSecureUrl($request));
}
示例6: testPrepareDataSource
/**
* @param array $data
* @param array $dataSourceItems
* @param array $expectedDataSourceItems
* @param string $expectedUrlPath
* @param array $expectedUrlParam
* @dataProvider prepareDataSourceDataProvider
*/
public function testPrepareDataSource($data, $dataSourceItems, $expectedDataSourceItems, $expectedUrlPath, $expectedUrlParam)
{
$this->model = $this->objectManager->getObject('Magento\\Sales\\Ui\\Component\\Listing\\Column\\ViewAction', ['urlBuilder' => $this->urlBuilder, 'data' => $data]);
$this->urlBuilder->expects($this->once())->method('getUrl')->with($expectedUrlPath, $expectedUrlParam)->willReturn('url');
$dataSource = ['data' => ['items' => $dataSourceItems]];
$dataSource = $this->model->prepareDataSource($dataSource);
$this->assertEquals($expectedDataSourceItems, $dataSource['data']['items']);
}
示例7: testGetButtonData
/**
* @param array $result
* @param bool $expectedValue
* @dataProvider getButtonDataProvider
*/
public function testGetButtonData($result, $expectedValue)
{
$this->registryMock->expects($this->any())->method('registry')->willReturn(1);
$this->customerRegistryMock->expects($this->once())->method('retrieve')->willReturn($this->customerModelMock);
$this->customerModelMock->expects($this->once())->method('isCustomerLocked')->willReturn($expectedValue);
$this->urlBuilderMock->expects($this->any())->method('getUrl')->willReturn('http://website.com/');
$this->assertEquals($result, $this->block->getButtonData());
}
示例8: testGetGridUrlSuccessfulUrl
public function testGetGridUrlSuccessfulUrl()
{
$roleId = 1;
$url = 'http://Success';
$this->requestInterfaceMock->expects($this->once())->method('getParam')->willReturn($roleId);
$this->urlInterfaceMock->expects($this->once())->method('getUrl')->willReturn($url);
$this->assertEquals($url, $this->model->getGridUrl());
}
示例9: 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();
}
示例10: testGetSessionCheckerJson
/**
* @return void
*/
public function testGetSessionCheckerJson()
{
$requestUrl = 'http://host/index.php/security/session/check';
$redirectUrl = 'http://host/index.php/admin';
$this->urlBuilder->expects($this->exactly(2))->method('getUrl')->willReturnOnConsecutiveCalls($requestUrl, $redirectUrl);
$value = ['requestUrl' => $requestUrl, 'redirectUrl' => $redirectUrl];
$this->jsonEncoderMock->expects($this->once())->method('encode')->with($value)->willReturn(json_encode($value));
$this->assertEquals(json_encode($value), $this->block->getSessionCheckerJson());
}
示例11: testPrepareDataSource
/**
* @param array $dataSourceItem
* @param string $scope
* @param int $scopeId
*
* @dataProvider getPrepareDataSourceDataProvider
*/
public function testPrepareDataSource($dataSourceItem, $scope, $scopeId)
{
$expectedDataSourceItem = ['name' => ['edit' => ['href' => 'http://magento.com/theme/design_config/edit', 'label' => new \Magento\Framework\Phrase('Edit')]]];
$expectedDataSource = ['data' => ['items' => [array_merge($expectedDataSourceItem, $dataSourceItem)]]];
$this->urlBuilder->expects($this->any())->method('getUrl')->with('theme/design_config/edit', ['scope' => $scope, 'scope_id' => $scopeId])->willReturn('http://magento.com/theme/design_config/edit');
$dataSource = ['data' => ['items' => [$dataSourceItem]]];
$dataSource = $this->component->prepareDataSource($dataSource);
$this->assertEquals($expectedDataSource, $dataSource);
}
示例12: testGetSid
/**
* @param mixed $sid
* @param bool $useFrontedSid
* @param bool $isOwnOriginUrl
* @param mixed $testSid
* @dataProvider dataProviderTestGetSid
*/
public function testGetSid($sid, $useFrontedSid, $isOwnOriginUrl, $testSid)
{
$this->scopeConfig->expects($this->any())->method('getValue')->with(\Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->will($this->returnValue($useFrontedSid));
$this->urlBuilder->expects($this->any())->method('isOwnOriginUrl')->will($this->returnValue($isOwnOriginUrl));
if ($testSid) {
$this->request->getQuery()->set($this->model->getSessionIdQueryParam($this->session), $testSid);
}
$this->assertEquals($sid, $this->model->getSid($this->session));
}
示例13: testPrepareDataSource
public function testPrepareDataSource()
{
$dataSource = ['data' => ['items' => [['entity_id' => 1]]]];
$expectedDataSource = ['data' => ['items' => [['entity_id' => 1, 'name' => ['edit' => ['href' => 'http://magento.com/customer/index/edit', 'label' => new \Magento\Framework\Phrase('Edit'), 'hidden' => false]]]]]];
$this->context->expects($this->once())->method('getFilterParam')->with('store_id')->willReturn(null);
$this->urlBuilder->expects($this->once())->method('getUrl')->with('customer/*/edit', ['id' => 1, 'store' => null])->willReturn('http://magento.com/customer/index/edit');
$dataSource = $this->component->prepareDataSource($dataSource);
$this->assertEquals($expectedDataSource, $dataSource);
}
示例14: testPrepareDataSource
public function testPrepareDataSource()
{
$fieldName = 'special_field';
$dataSource = ['data' => ['items' => [[$fieldName => 'special_value1', 'entity_id' => null], ['entity_id' => '2'], [$fieldName => 'special_value3', 'entity_id' => '3']]]];
$result = ['data' => ['items' => [[$fieldName => 'special_value1', 'entity_id' => null], ['entity_id' => '2'], [$fieldName => 'special_value3', 'entity_id' => '3', 'product_link' => '<a href="/catalog/product/edit/id/3" target="_blank">special_value3</a>']]]];
$this->urlBuilderMock->expects(static::any())->method('getUrl')->willReturnMap([['catalog/product/edit', ['id' => '3'], '/catalog/product/edit/id/3']]);
$this->nameColumn->setData('name', $fieldName);
$this->assertSame($result, $this->nameColumn->prepareDataSource($dataSource));
}
示例15: testGetTargetStorePostData
public function testGetTargetStorePostData()
{
$store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
$store->expects($this->any())->method('getCode')->will($this->returnValue('new-store'));
$storeSwitchUrl = 'stores/store/switch';
$this->urlBuilder->expects($this->any())->method('getUrl')->with($storeSwitchUrl)->willReturnArgument(0);
$this->corePostDataHelper->expects($this->any())->method('getPostData')->with($storeSwitchUrl, ['___store' => 'new-store']);
$this->switcher->getTargetStorePostData($store);
}