Example #1
0
 public function testGetSampleData()
 {
     $expectingFileData = ['sample_file' => ['file' => 'file/sample.gif', 'name' => '<a href="final_url">sample.gif</a>', 'size' => '1.1', 'status' => 'old']];
     $this->productModel->expects($this->any())->method('getTypeId')->will($this->returnValue('downloadable'));
     $this->productModel->expects($this->any())->method('getTypeInstance')->will($this->returnValue($this->downloadableProductModel));
     $this->productModel->expects($this->any())->method('getStoreId')->will($this->returnValue(0));
     $this->downloadableProductModel->expects($this->any())->method('getSamples')->will($this->returnValue([$this->downloadableSampleModel]));
     $this->coreRegistry->expects($this->any())->method('registry')->will($this->returnValue($this->productModel));
     $this->downloadableSampleModel->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->downloadableSampleModel->expects($this->any())->method('getTitle')->will($this->returnValue('Sample Title'));
     $this->downloadableSampleModel->expects($this->any())->method('getSampleUrl')->will($this->returnValue(null));
     $this->downloadableSampleModel->expects($this->any())->method('getSampleFile')->will($this->returnValue('file/sample.gif'));
     $this->downloadableSampleModel->expects($this->any())->method('getSampleType')->will($this->returnValue('file'));
     $this->downloadableSampleModel->expects($this->any())->method('getSortOrder')->will($this->returnValue(0));
     $this->escaper->expects($this->any())->method('escapeHtml')->will($this->returnValue('Sample Title'));
     $this->fileHelper->expects($this->any())->method('getFilePath')->will($this->returnValue('/file/path/sample.gif'));
     $this->fileHelper->expects($this->any())->method('ensureFileInFilesystem')->will($this->returnValue(true));
     $this->fileHelper->expects($this->any())->method('getFileSize')->will($this->returnValue('1.1'));
     $this->urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue('final_url'));
     $sampleData = $this->block->getSampleData();
     foreach ($sampleData as $sample) {
         $fileSave = $sample->getFileSave(0);
         $this->assertEquals($expectingFileData['sample_file'], $fileSave);
     }
 }
Example #2
0
 public function testGetTreeLoaderUrl()
 {
     $requestParams = [\Magento\Theme\Helper\Storage::PARAM_THEME_ID => 1, \Magento\Theme\Helper\Storage::PARAM_CONTENT_TYPE => \Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE, \Magento\Theme\Helper\Storage::PARAM_NODE => 'root'];
     $expectedUrl = 'some_url';
     $this->_helperStorage->expects($this->once())->method('getRequestParams')->will($this->returnValue($requestParams));
     $this->_urlBuilder->expects($this->once())->method('getUrl')->with('adminhtml/*/treeJson', $requestParams)->will($this->returnValue($expectedUrl));
     $this->assertEquals($expectedUrl, $this->_filesTree->getTreeLoaderUrl());
 }
Example #3
0
 public function testGetJsUploadUrl()
 {
     $themeId = 2;
     $uploadUrl = 'upload_url';
     $themeMock = $this->getMock('Magento\\Theme\\Model\\Theme', ['isVirtual', 'getId', '__wakeup'], [], '', false);
     $themeMock->expects($this->any())->method('getId')->will($this->returnValue($themeId));
     $this->_model->expects($this->any())->method('_getCurrentTheme')->will($this->returnValue($themeMock));
     $this->_urlBuilder->expects($this->once())->method('getUrl')->with('adminhtml/system_design_theme/uploadjs', ['id' => $themeId])->will($this->returnValue($uploadUrl));
     $this->assertEquals($uploadUrl, $this->_model->getJsUploadUrl());
 }
 public function testGetLinkData()
 {
     $expectingFileData = array('file' => array('file' => 'file/link.gif', 'name' => '<a href="final_url">link.gif</a>', 'size' => '1.1', 'status' => 'old'), 'sample_file' => array('file' => 'file/sample.gif', 'name' => '<a href="final_url">sample.gif</a>', 'size' => '1.1', 'status' => 'old'));
     $this->productModel->expects($this->any())->method('getTypeId')->will($this->returnValue('downloadable'));
     $this->productModel->expects($this->any())->method('getTypeInstance')->will($this->returnValue($this->downloadableProductModel));
     $this->productModel->expects($this->any())->method('getStoreId')->will($this->returnValue(0));
     $this->downloadableProductModel->expects($this->any())->method('getLinks')->will($this->returnValue(array($this->downloadableLinkModel)));
     $this->coreRegistry->expects($this->any())->method('registry')->will($this->returnValue($this->productModel));
     $this->downloadableLinkModel->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->downloadableLinkModel->expects($this->any())->method('getTitle')->will($this->returnValue('Link Title'));
     $this->downloadableLinkModel->expects($this->any())->method('getPrice')->will($this->returnValue('10'));
     $this->downloadableLinkModel->expects($this->any())->method('getNumberOfDownloads')->will($this->returnValue('6'));
     $this->downloadableLinkModel->expects($this->any())->method('getLinkUrl')->will($this->returnValue(null));
     $this->downloadableLinkModel->expects($this->any())->method('getLinkType')->will($this->returnValue('file'));
     $this->downloadableLinkModel->expects($this->any())->method('getSampleFile')->will($this->returnValue('file/sample.gif'));
     $this->downloadableLinkModel->expects($this->any())->method('getSampleType')->will($this->returnValue('file'));
     $this->downloadableLinkModel->expects($this->any())->method('getSortOrder')->will($this->returnValue(0));
     $this->downloadableLinkModel->expects($this->any())->method('getLinkFile')->will($this->returnValue('file/link.gif'));
     $this->downloadableLinkModel->expects($this->any())->method('getStoreTitle')->will($this->returnValue('Store Title'));
     $this->escaper->expects($this->any())->method('escapeHtml')->will($this->returnValue('Link Title'));
     $this->fileHelper->expects($this->any())->method('getFilePath')->will($this->returnValue('/file/path/link.gif'));
     $this->fileHelper->expects($this->any())->method('ensureFileInFilesystem')->will($this->returnValue(true));
     $this->fileHelper->expects($this->any())->method('getFileSize')->will($this->returnValue('1.1'));
     $this->urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue('final_url'));
     $linkData = $this->block->getLinkData();
     foreach ($linkData as $link) {
         $fileSave = $link->getFileSave(0);
         $sampleFileSave = $link->getSampleFileSave(0);
         $this->assertEquals($expectingFileData['file'], $fileSave);
         $this->assertEquals($expectingFileData['sample_file'], $sampleFileSave);
     }
 }
Example #5
0
 public function testGetContentsUrl()
 {
     $expectedUrl = 'some_url';
     $expectedRequest = 'some_request';
     $requestParams = [\Magento\Theme\Helper\Storage::PARAM_THEME_ID => 1, \Magento\Theme\Helper\Storage::PARAM_CONTENT_TYPE => \Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE, \Magento\Theme\Helper\Storage::PARAM_NODE => 'root'];
     $this->_urlBuilder->expects($this->once())->method('getUrl')->with('adminhtml/*/contents', ['type' => $expectedRequest] + $requestParams)->will($this->returnValue($expectedUrl));
     $this->_request->expects($this->once())->method('getParam')->with('type')->will($this->returnValue($expectedRequest));
     $this->_helperStorage->expects($this->once())->method('getRequestParams')->will($this->returnValue($requestParams));
     $this->assertEquals($expectedUrl, $this->_filesContent->getContentsUrl());
 }
 /**
  * @param null|string $requestCountry
  * @param null|string $requestDefaultCountry
  * @param bool $canUseDefault
  * @param bool $inherit
  * @dataProvider renderDataProvider
  */
 public function testRender($requestCountry, $requestDefaultCountry, $canUseDefault, $inherit)
 {
     $this->_request->expects($this->any())->method('getParam')->will($this->returnCallback(function ($param) use($requestCountry, $requestDefaultCountry) {
         if ($param == \Magento\Paypal\Model\Config\StructurePlugin::REQUEST_PARAM_COUNTRY) {
             return $requestCountry;
         }
         if ($param == Country::REQUEST_PARAM_DEFAULT_COUNTRY) {
             return $requestDefaultCountry;
         }
         return $param;
     }));
     $this->_element->setInherit($inherit);
     $this->_element->setCanUseDefaultValue($canUseDefault);
     $constraints = [new \PHPUnit_Framework_Constraint_StringContains('document.observe("dom:loaded", function() {'), new \PHPUnit_Framework_Constraint_StringContains('$("' . $this->_element->getHtmlId() . '").observe("change", function () {')];
     if ($canUseDefault && $requestCountry == 'US' && $requestDefaultCountry) {
         $constraints[] = new \PHPUnit_Framework_Constraint_StringContains('$("' . $this->_element->getHtmlId() . '_inherit").observe("click", function () {');
     }
     $this->_jsHelper->expects($this->once())->method('getScript')->with(new \PHPUnit_Framework_Constraint_And($constraints));
     $this->_url->expects($this->once())->method('getUrl')->with('*/*/*', ['section' => 'section', 'website' => 'website', 'store' => 'store', \Magento\Paypal\Model\Config\StructurePlugin::REQUEST_PARAM_COUNTRY => '__country__']);
     $this->_model->render($this->_element);
 }
Example #7
0
 public function testGetSaveCustomCssUrl()
 {
     $expectedUrl = 'some_url';
     $this->_urlBuilder->expects($this->once())->method('getUrl')->with('adminhtml/system_design_editor_tools/saveCssContent', ['theme_id' => self::TEST_THEME_ID])->will($this->returnValue($expectedUrl));
     $this->assertEquals($expectedUrl, $this->_model->getSaveCustomCssUrl());
 }
Example #8
0
 public function testGetRedirectIframeUrl()
 {
     $params = array('some params');
     $this->_urlBuilder->expects($this->once())->method('getUrl')->with($this->equalTo('adminhtml/authorizenet_directpost_payment/redirect'), $this->equalTo($params))->will($this->returnValue('some value'));
     $this->assertEquals('some value', $this->_model->getRedirectIframeUrl($params));
 }
Example #9
0
 public function testGetRedirectIframeUrl()
 {
     $params = ['some params', '_secure' => true];
     $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('adminhtml/authorizenet_directpost_payment/redirect', $params)->willReturn('some value');
     $this->assertEquals('some value', $this->dataHelper->getRedirectIframeUrl($params));
 }
Example #10
0
 /**
  * @covers \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\Js::getJsReorderUrl
  */
 public function testGetJsReorderUrl()
 {
     $expectedUrl = 'some_url';
     $this->_urlBuilder->expects($this->once())->method('getUrl')->with('adminhtml/system_design_editor_tools/reorderjs', array('theme_id' => self::TEST_THEME_ID))->will($this->returnValue($expectedUrl));
     $this->assertEquals($expectedUrl, $this->_model->getJsReorderUrl());
 }