Ejemplo n.º 1
0
 /**
  * @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());
 }
Ejemplo n.º 2
0
 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']);
 }
Ejemplo n.º 3
0
 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));
 }
Ejemplo n.º 4
0
 /**
  * @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();
 }
Ejemplo n.º 5
0
 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));
 }
Ejemplo n.º 6
0
 /**
  * @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']);
 }
 /**
  * @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());
 }
Ejemplo n.º 8
0
 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());
 }
Ejemplo n.º 9
0
 /**
  * @covers \Magento\PageCache\Block\Javascript::getScriptOptions
  * @param bool $isSecure
  * @param string $url
  * @param string $expectedResult
  * @dataProvider getScriptOptionsDataProvider
  */
 public function testGetScriptOptions($isSecure, $url, $expectedResult)
 {
     $handles = ['some', 'handles', 'here'];
     $this->requestMock->expects($this->once())->method('isSecure')->willReturn($isSecure);
     $this->urlBuilderMock->expects($this->once())->method('getUrl')->willReturn($url);
     $this->layoutUpdateMock->expects($this->once())->method('getHandles')->willReturn($handles);
     $this->assertRegExp($expectedResult, $this->blockJavascript->getScriptOptions());
 }
Ejemplo n.º 10
0
 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();
 }
Ejemplo n.º 11
0
 /**
  * @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());
 }
 /**
  * @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);
 }
Ejemplo n.º 13
0
 /**
  * @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));
 }
Ejemplo n.º 14
0
 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);
 }
Ejemplo n.º 15
0
 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));
 }
Ejemplo n.º 16
0
 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);
 }
Ejemplo n.º 17
0
 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());
 }
Ejemplo n.º 18
0
 protected function setUp()
 {
     $this->productLocatorMock = $this->getMockBuilder(LocatorInterface::class)->getMockForAbstractClass();
     $this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)->getMockForAbstractClass();
     $this->productMock = $this->getMockBuilder(ProductInterface::class)->getMockForAbstractClass();
     $this->productLocatorMock->expects(static::any())->method('getProduct')->willReturn($this->productMock);
     $this->urlBuilderMock->expects(static::any())->method('addSessionParam')->willReturnSelf();
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->configurablePanelModifier = $this->objectManagerHelper->getObject(ConfigurablePanelModifier::class, ['locator' => $this->productLocatorMock, 'urlBuilder' => $this->urlBuilderMock]);
 }
Ejemplo n.º 19
0
 public function testEvaluate()
 {
     $input = array('path' => 'some/path');
     $expected = 'http://some.domain.com/some/path/';
     $urlParams = array('param');
     $this->_interpreter->expects($this->once())->method('evaluate')->with($input)->will($this->returnValue($urlParams));
     $this->_urlResolver->expects($this->once())->method('getUrl')->with('some/path', $urlParams)->will($this->returnValue($expected));
     $actual = $this->_model->evaluate($input);
     $this->assertSame($expected, $actual);
 }
 public function testGetButtonData()
 {
     $url = 'test';
     $this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/')->willReturn($url);
     $result = $this->block->getButtonData();
     $this->assertArrayHasKey('label', $result);
     $this->assertEquals($result['label'], __('Back'));
     $this->assertArrayHasKey('on_click', $result);
     $this->assertEquals($result['on_click'], "location.href = '{$url}';");
 }
 public function testGetConfig()
 {
     $loginUrl = 'http://base-url.test/customer/login';
     $baseUrl = 'http://base-url.test';
     $this->urlBuilder->expects($this->exactly(2))->method('getUrl')->with(Url::ROUTE_ACCOUNT_LOGIN)->willReturn($loginUrl);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($this->store);
     $this->store->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl);
     $this->scopeConfig->expects($this->once())->method('getValue')->with(Form::XML_PATH_ENABLE_AUTOCOMPLETE, ScopeInterface::SCOPE_STORE)->willReturn(0);
     $this->assertEquals(['customerLoginUrl' => $loginUrl, 'isRedirectRequired' => false, 'autocomplete' => 'off'], $this->provider->getConfig());
 }
Ejemplo n.º 22
0
 public function testGetTargetStorePostData()
 {
     $urlRewrite = $this->getMock('Magento\\UrlRewrite\\Service\\V1\\Data\\UrlRewrite');
     $urlRewrite->expects($this->once())->method('getRequestPath')->willReturn('path');
     $this->request->expects($this->once())->method('getPathInfo')->willReturn('path');
     $this->urlFinder->expects($this->once())->method('findOneByData')->willReturn($urlRewrite);
     $this->urlHelper->expects($this->once())->method('getEncodedUrl')->willReturn('encoded-path');
     $this->urlBuilder->expects($this->once())->method('getUrl')->willReturn('path');
     $this->assertEquals([$this->store, [\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => 'encoded-path']], $this->unit->beforeGetTargetStorePostData($this->switcher, $this->store, []));
 }
Ejemplo n.º 23
0
 public function testGetCacheKeyInfo()
 {
     $nodeFactory = $this->getMock('Magento\\Framework\\Data\\Tree\\NodeFactory', [], [], '', false);
     $treeFactory = $this->getMock('Magento\\Framework\\Data\\TreeFactory', [], [], '', false);
     $topmenu = new Topmenu($this->context, $nodeFactory, $treeFactory);
     $this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn('123');
     $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['getCode'])->getMock();
     $store->expects($this->once())->method('getCode')->willReturn('321');
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($store);
     $this->assertEquals(['BLOCK_TPL', '321', null, 'template' => null, '123'], $topmenu->getCacheKeyInfo());
 }
Ejemplo n.º 24
0
 /**
  * @covers \Magento\Framework\App\Helper\AbstractHelper::urlEncode
  * @covers \Magento\Framework\App\Helper\AbstractHelper::urlDecode
  */
 public function testUrlDecode()
 {
     $data = uniqid();
     $result = $this->helper->urlEncode($data);
     $this->urlBuilderMock->expects($this->once())->method('sessionUrlVar')->with($this->equalTo($data))->will($this->returnValue($result));
     $this->assertNotContains('&', $result);
     $this->assertNotContains('%', $result);
     $this->assertNotContains('+', $result);
     $this->assertNotContains('=', $result);
     $this->assertEquals($result, $this->helper->urlDecode($result));
 }
Ejemplo n.º 25
0
 /**
  * @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)
 {
     $contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
     $processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
     $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor);
     $this->model = $this->objectManager->getObject('Magento\\Sales\\Ui\\Component\\Listing\\Column\\ViewAction', ['urlBuilder' => $this->urlBuilder, 'data' => $data, 'context' => $contextMock]);
     $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']);
 }
Ejemplo n.º 26
0
 public function testGetRssData()
 {
     $this->rssUrlBuilder->expects($this->once())->method('getUrl')->will($this->returnValue('http://magento.com/rss/feeds/index/type/notifystock'));
     $item = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->setMethods(['__sleep', '__wakeup', 'getId', 'getQty', 'getName'])->disableOriginalConstructor()->getMock();
     $item->expects($this->once())->method('getId')->will($this->returnValue(1));
     $item->expects($this->once())->method('getQty')->will($this->returnValue(1));
     $item->expects($this->any())->method('getName')->will($this->returnValue('Low Stock Product'));
     $this->rssModel->expects($this->once())->method('getProductsCollection')->will($this->returnValue([$item]));
     $this->urlBuilder->expects($this->once())->method('getUrl')->with('catalog/product/edit', ['id' => 1, '_secure' => true, '_nosecret' => true])->will($this->returnValue('http://magento.com/catalog/product/edit/id/1'));
     $this->assertEquals($this->rssFeed, $this->block->getRssData());
 }
Ejemplo n.º 27
0
 protected function setUp()
 {
     $this->escaperMock = $this->getMock('Magento\\Framework\\Escaper', [], [], '', false);
     $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0);
     $this->urlBuilderMock = $this->getMock('Magento\\Framework\\UrlInterface', [], [], '', false);
     $this->urlBuilderMock->expects($this->any())->method('getUrl')->willReturn('http://magento.loc/linkurl');
     $this->contextMock = $this->getMock('Magento\\Backend\\Block\\Context', ['getEscaper', 'getUrlBuilder'], [], '', false);
     $this->contextMock->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaperMock));
     $this->contextMock->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($this->urlBuilderMock));
     $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->nameRenderer = $this->objectManagerHelper->getObject('Magento\\Integration\\Block\\Adminhtml\\Widget\\Grid\\Column\\Renderer\\Name', ['context' => $this->contextMock]);
 }
Ejemplo n.º 28
0
 public function testAfterLoad()
 {
     $value = 'filename.jpg';
     $this->fileBackend->setValue($value);
     $this->fileBackend->setFieldConfig(['upload_dir' => ['value' => 'value', 'config' => 'system/filesystem/media'], 'base_url' => ['type' => 'media', 'value' => 'design/file']]);
     $this->mediaDirectory->expects($this->once())->method('isExist')->with('value/' . $value)->willReturn(true);
     $this->urlBuilder->expects($this->once())->method('getBaseUrl')->with(['_type' => UrlInterface::URL_TYPE_MEDIA])->willReturn('http://magento2.com/pub/media/');
     $this->mediaDirectory->expects($this->once())->method('getRelativePath')->with('value')->willReturn('value');
     $this->mediaDirectory->expects($this->once())->method('stat')->with('value/' . $value)->willReturn(['size' => 234234]);
     $this->fileBackend->afterLoad();
     $this->assertEquals([['url' => 'http://magento2.com/pub/media/design/file/' . $value, 'file' => $value, 'size' => 234234, 'exists' => true]], $this->fileBackend->getValue());
 }
Ejemplo n.º 29
0
 public function testPrepareDataSource()
 {
     $entityId = 1;
     $url = 'url';
     $itemName = 'itemName';
     $oldItemValue = 'itemValue';
     $newItemValue = ['view' => ['href' => $url, 'label' => __('View')]];
     $dataSource = ['data' => ['items' => [[$itemName => $oldItemValue, 'entity_id' => $entityId]]]];
     $this->urlBuilder->expects($this->once())->method('getUrl')->with(OrderActions::URL_PATH_VIEW, ['order_id' => $entityId])->willReturn($url);
     $this->model->setData('name', $itemName);
     $this->model->prepareDataSource($dataSource);
     $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
 }
Ejemplo n.º 30
0
 public function getViewFileUrlWithException()
 {
     $params = ['a' => 'b'];
     $paramsSecure = ['a' => 'b', '_secure' => false];
     $fileId = 'file id';
     $fileUrl = 'exception url';
     $this->requestMock->expects($this->once())->method('isSecure')->willReturn(false);
     $exception = new LocalizedException('message');
     $this->repositoryMock->expects($this->once())->method('getUrlWithParams')->with($fileId, $paramsSecure)->willThrowException($exception);
     $this->loggerMock->expects($this->once())->method('critical')->with($exception);
     $this->urlMock->expects($this->once())->method('getUrl')->with('', ['_direct' => 'core/index/notFound'])->willReturn($fileUrl);
     $this->assertEquals($fileUrl, $this->model->getViewFileUrl($fileId, $params));
 }