public function testGetLinkData() { $expectingFileData = ['file' => ['file' => 'file/link.gif', 'name' => '<a href="final_url">link.gif</a>', 'size' => '1.1', 'status' => 'old'], '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('getLinks')->will($this->returnValue([$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); } }
protected function setUp() { $this->methodMock = $this->getMock('Magento\\OfflinePayments\\Model\\Checkmo', [], [], '', false); $paymentHelperMock = $this->getMock('Magento\\Payment\\Helper\\Data', [], [], '', false); $paymentHelperMock->expects($this->once())->method('getMethodInstance')->with(Checkmo::PAYMENT_METHOD_CHECKMO_CODE)->willReturn($this->methodMock); $this->escaperMock = $this->getMock('Magento\\Framework\\Escaper'); $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); $this->model = new CheckmoConfigProvider($paymentHelperMock, $this->escaperMock); }
protected function setUp() { $this->escaperMock = $this->getMock('Magento\\Framework\\Escaper', [], [], '', false); $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); $this->contextMock = $this->getMock('Magento\\Backend\\Block\\Context', ['getEscaper'], [], '', false); $this->contextMock->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaperMock)); $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->buttonRenderer = $this->objectManagerHelper->getObject('Magento\\Integration\\Block\\Adminhtml\\Widget\\Grid\\Column\\Renderer\\Button', ['context' => $this->contextMock]); }
public function testGetHtml() { $resultHtml = '<input type="text" name="escapedHtml" ' . 'id="escapedHtml" value="escapedHtml" ' . 'class="input-text admin__control-text no-changes" data-ui-id="filter-escapedhtml" />'; $column = $this->getMockBuilder('Magento\\Backend\\Block\\Widget\\Grid\\Column')->setMethods(['getId', 'getHtmlId'])->disableOriginalConstructor()->getMock(); $this->block->setColumn($column); $this->escaper->expects($this->any())->method('escapeHtml')->willReturn('escapedHtml'); $column->expects($this->any())->method('getId')->willReturn('id'); $column->expects($this->once())->method('getHtmlId')->willReturn('htmlId'); $this->assertEquals($resultHtml, $this->block->getHtml()); }
protected function setUp() { $this->methodOneMock = $this->getMock('Magento\\Payment\\Model\\Method\\AbstractMethod', ['isAvailable', 'getInstructions'], [], '', false); $this->methodTwoMock = $this->getMock('Magento\\Payment\\Model\\Method\\AbstractMethod', ['isAvailable', 'getInstructions'], [], '', false); $paymentHelperMock = $this->getMock('Magento\\Payment\\Helper\\Data', [], [], '', false); $paymentHelperMock->expects($this->exactly(2))->method('getMethodInstance')->willReturnMap([[Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE, $this->methodOneMock], [Cashondelivery::PAYMENT_METHOD_CASHONDELIVERY_CODE, $this->methodTwoMock]]); $this->escaperMock = $this->getMock('Magento\\Framework\\Escaper'); $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); $this->model = new InstructionsConfigProvider($paymentHelperMock, $this->escaperMock); }
/** * @dataProvider prepareDataSourceDataProvider */ public function testPrepareDataSource($dataSource, $expectedResult) { $website = 'website'; $group = 'group'; $store = 'store'; $storeStructure = [1 => ['value' => 1, 'label' => $website, 'children' => [1 => ['value' => 1, 'label' => $group, 'children' => [1 => ['value' => 1, 'label' => $store]]]]]]; $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnMap([[$group, null, $group], [$store, null, $store]]); $this->systemStoreMock->expects($this->any())->method('getStoresStructure')->willReturn($storeStructure); $this->assertEquals($this->model->prepareDataSource($dataSource), $expectedResult); }
/** * @covers \Magento\Cms\Block\Adminhtml\Block\Edit::getHeaderText * @param integer|null $modelBlockId * * @dataProvider getHeaderTextDataProvider */ public function testGetHeaderText($modelBlockId) { $title = 'some title'; $escapedTitle = 'escaped title'; $this->registryMock->expects($this->atLeastOnce())->method('registry')->with('cms_block')->willReturn($this->modelBlockMock); $this->modelBlockMock->expects($this->atLeastOnce())->method('getId')->willReturn($modelBlockId); $this->modelBlockMock->expects($this->any())->method('getTitle')->willReturn($title); $this->escaperMock->expects($this->any())->method('escapeHtml')->with($title)->willReturn($escapedTitle); $this->assertInternalType('string', $this->this->getHeaderText()); }
/** * @covers \Magento\Cms\Block\Adminhtml\Block\Edit::getHeaderText * @param integer|null $modelBlockId * * @dataProvider getHeaderTextDataProvider */ public function testGetHeaderText($modelBlockId) { $title = 'some title'; $escapedTitle = 'escaped title'; $this->registryMock->expects($this->atLeastOnce())->method('registry')->with('cms_block')->willReturn($this->modelBlockMock); $this->modelBlockMock->expects($this->atLeastOnce())->method('getId')->willReturn($modelBlockId); $this->modelBlockMock->expects($this->any())->method('getTitle')->willReturn($title); $this->escaperMock->expects($this->any())->method('escapeHtml')->with($title)->willReturn($escapedTitle); $this->assertInstanceOf('Magento\\Framework\\Phrase', $this->this->getHeaderText()); }
public function testExecute() { //Data $formKey = '<asdfaswqrwqe12>'; $escapedFormKey = 'asdfaswqrwqe12'; //Verification $this->_formKey->expects($this->once())->method('get')->will($this->returnValue($formKey)); $this->_escaper->expects($this->once())->method('escapeHtml')->with($formKey)->will($this->returnValue($escapedFormKey)); $this->_session->expects($this->once())->method('setData')->with(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $escapedFormKey); $this->_model->execute(); }
/** * @dataProvider queryTextDataProvider */ public function testGetEscapedQueryText($queryText, $maxQueryLength, $expected) { $this->requestMock->expects($this->once())->method('getParam')->willReturn($queryText); $this->stringMock->expects($this->any())->method('cleanString')->willReturnArgument(0); $this->scopeConfigMock->expects($this->any())->method('getValue')->willReturn($maxQueryLength); $this->stringMock->expects($this->any())->method('strlen')->will($this->returnCallback(function ($queryText) { return strlen($queryText); })); $this->stringMock->expects($this->any())->method('substr')->with($queryText, 0, $maxQueryLength)->willReturn($expected); $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); $this->assertEquals($expected, $this->model->getEscapedQueryText()); }
protected function setUp() { $this->pageConfigMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock(); $this->assetMergeServiceMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\MergeService')->disableOriginalConstructor()->getMock(); $this->urlBuilderMock = $this->getMockForAbstractClass('Magento\\Framework\\UrlInterface'); $this->escaperMock = $this->getMockBuilder('Magento\\Framework\\Escaper')->disableOriginalConstructor()->getMock(); $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); $this->stringMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\StringUtils')->disableOriginalConstructor()->getMock(); $this->loggerMock = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $this->assetsCollection = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\GroupedCollection')->setMethods(['getGroups'])->disableOriginalConstructor()->getMock(); $this->assetInterfaceMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Asset\\AssetInterface'); $this->titleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->setMethods(['set', 'get'])->disableOriginalConstructor()->getMock(); $this->objectManagerHelper = new ObjectManager($this); $this->renderer = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Page\\Config\\Renderer', ['pageConfig' => $this->pageConfigMock, 'assetMergeService' => $this->assetMergeServiceMock, 'urlBuilder' => $this->urlBuilderMock, 'escaper' => $this->escaperMock, 'string' => $this->stringMock, 'logger' => $this->loggerMock]); }
/** * @param string $actionName * @return \Magento\Integration\Controller\Adminhtml\Integration */ protected function _createIntegrationController($actionName) { // Mock Layout passed into constructor $this->_viewMock = $this->getMock('Magento\\Framework\\App\\ViewInterface'); $this->_layoutMock = $this->getMock('Magento\\Framework\\View\\LayoutInterface'); $this->_layoutMergeMock = $this->getMockBuilder('Magento\\Core\\Model\\Layout\\Merge')->disableOriginalConstructor()->getMock(); $this->_layoutMock->expects($this->any())->method('getUpdate')->will($this->returnValue($this->_layoutMergeMock)); $testElement = new \Magento\Framework\Simplexml\Element('<test>test</test>'); $this->_layoutMock->expects($this->any())->method('getNode')->will($this->returnValue($testElement)); // for _setActiveMenu $this->_viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->_layoutMock)); $blockMock = $this->getMockBuilder('Magento\\Backend\\Block\\Menu')->disableOriginalConstructor()->getMock(); $menuMock = $this->getMock('Magento\\Backend\\Model\\Menu', [], [$this->getMock('Magento\\Framework\\Logger', [], [], '', false)]); $loggerMock = $this->getMockBuilder('Magento\\Framework\\Logger')->disableOriginalConstructor()->getMock(); $loggerMock->expects($this->any())->method('logException')->will($this->returnSelf()); $menuMock->expects($this->any())->method('getParentItems')->will($this->returnValue(array())); $blockMock->expects($this->any())->method('getMenuModel')->will($this->returnValue($menuMock)); $this->_layoutMock->expects($this->any())->method('getMessagesBlock')->will($this->returnValue($blockMock)); $this->_layoutMock->expects($this->any())->method('getBlock')->will($this->returnValue($blockMock)); $this->_escaper->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0)); $contextParameters = array('view' => $this->_viewMock, 'objectManager' => $this->_objectManagerMock, 'session' => $this->_backendSessionMock, 'translator' => $this->_translateModelMock, 'request' => $this->_requestMock, 'response' => $this->_responseMock, 'messageManager' => $this->_messageManager); $this->_backendActionCtxMock = $this->_objectManagerHelper->getObject('Magento\\Backend\\App\\Action\\Context', $contextParameters); $integrationCollection = $this->getMockBuilder('\\Magento\\Integration\\Model\\Resource\\Integration\\Collection')->disableOriginalConstructor()->setMethods(['addUnsecureUrlsFilter', 'getSize'])->getMock(); $integrationCollection->expects($this->any())->method('addUnsecureUrlsFilter')->will($this->returnValue($integrationCollection)); $integrationCollection->expects($this->any())->method('getSize')->will($this->returnValue(0)); $subControllerParams = array('context' => $this->_backendActionCtxMock, 'integrationService' => $this->_integrationSvcMock, 'oauthService' => $this->_oauthSvcMock, 'registry' => $this->_registryMock, 'logger' => $loggerMock, 'integrationData' => $this->_integrationHelperMock, 'escaper' => $this->_escaper, 'integrationCollection' => $integrationCollection); /** Create IntegrationController to test */ $controller = $this->_objectManagerHelper->getObject('\\Magento\\Integration\\Controller\\Adminhtml\\Integration\\' . $actionName, $subControllerParams); return $controller; }
public function testGetSampleData() { $expectingFileData = array('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('getSamples')->will($this->returnValue(array($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); } }
/** * @param array $initialData * @param string $expectedValue * @dataProvider addElementValuesDataProvider * @covers \Magento\Framework\Data\Form\Element\AbstractElement::addElementValues() */ public function testAddElementValues(array $initialData, $expectedValue) { $this->_escaperMock->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0)); $this->_model->setValues($initialData['initial_values']); $this->_model->addElementValues($initialData['add_values'], $initialData['overwrite']); $this->assertEquals($expectedValue, $this->_model->getValues()); }
public function testGetItemDefault() { $this->escaper->expects($this->once())->method('escapeHtml')->with('value', null); $item = $this->getMock('Magento\\Paypal\\Model\\Billing\\Agreement', [], [], '', false); $item->expects($this->exactly(2))->method('getData')->with('default')->willReturn('value'); $this->block->getItemValue($item, 'default'); }
/** * @param bool $noDiscount * @param string $couponCode * @param string $errorMessage * @param string $actualCouponCode * @dataProvider isApplyDiscountDataProvider */ public function testExecute($noDiscount, $couponCode, $errorMessage, $actualCouponCode) { $quote = $this->getMock('Magento\\Quote\\Model\\Quote', ['getCouponCode', 'isVirtual', 'getAllItems'], [], '', false); $create = $this->getMock('Magento\\Sales\\Model\\AdminOrder\\Create', [], [], '', false); $paramReturnMap = [['customer_id', null, null], ['store_id', null, null], ['currency_id', null, null]]; $this->request->expects($this->atLeastOnce())->method('getParam')->willReturnMap($paramReturnMap); $objectManagerParamMap = [['Magento\\Sales\\Model\\AdminOrder\\Create', $create], ['Magento\\Backend\\Model\\Session\\Quote', $this->session]]; $this->objectManager->expects($this->atLeastOnce())->method('get')->willReturnMap($objectManagerParamMap); $this->eventManager->expects($this->any())->method('dispatch'); $data = ['coupon' => ['code' => $couponCode]]; $postReturnMap = [['order', $data], ['reset_shipping', false], ['collect_shipping_rates', false], ['sidebar', false], ['add_product', false], ['', false], ['update_items', false], ['remove_item', 1], ['from', 2], ['move_item', 1], ['to', 2], ['qty', 3], ['payment', false], [null, 'request'], ['payment', false], ['giftmessage', false], ['add_products', false], ['update_items', false]]; $this->request->expects($this->atLeastOnce())->method('getPost')->willReturnMap($postReturnMap); $create->expects($this->once())->method('importPostData')->willReturnSelf(); $create->expects($this->once())->method('initRuleData')->willReturnSelf(); $create->expects($this->any())->method('getQuote')->willReturn($quote); $address = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', [], [], '', false); $create->expects($this->once())->method('getBillingAddress')->willReturn($address); $quote->expects($this->any())->method('isVirtual')->willReturn(true); $this->request->expects($this->once())->method('has')->with('item')->willReturn(false); $create->expects($this->once())->method('saveQuote')->willReturnSelf(); $this->session->expects($this->any())->method('getQuote')->willReturn($quote); $item = $this->getMockForAbstractClass('Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection', [], '', false, true, true, ['getNoDiscount']); $quote->expects($this->any())->method('getAllItems')->willReturn([$item]); $item->expects($this->any())->method('getNoDiscount')->willReturn($noDiscount); if (!$noDiscount) { $quote->expects($this->once())->method('getCouponCode')->willReturn($actualCouponCode); } $errorMessageManager = __($errorMessage, $couponCode); $this->escaper->expects($this->once())->method('escapeHtml')->with($couponCode)->willReturn($couponCode); $this->messageManager->expects($this->once())->method('addError')->with($errorMessageManager)->willReturnSelf(); $this->resultForward->expects($this->once())->method('forward')->with('index')->willReturnSelf(); $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Forward', $this->processData->execute()); }
/** * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser::prepareElementHtml * @param string $elementValue * @param integer|null $modelBlockId * * @dataProvider prepareElementHtmlDataProvider */ public function testPrepareElementHtml($elementValue, $modelBlockId) { $elementId = 1; $uniqId = '126hj4h3j73hk7b347jhkl37gb34'; $sourceUrl = 'cms/block_widget/chooser/126hj4h3j73hk7b347jhkl37gb34'; $config = ['key1' => 'value1']; $fieldsetId = 2; $html = 'some html'; $title = 'some "><img src=y onerror=prompt(document.domain)>; title'; $titleEscaped = 'some "><img src=y onerror=prompt(document.domain)>; title'; $this->this->setConfig($config); $this->this->setFieldsetId($fieldsetId); $this->elementMock->expects($this->atLeastOnce())->method('getId')->willReturn($elementId); $this->mathRandomMock->expects($this->atLeastOnce())->method('getUniqueHash')->with($elementId)->willReturn($uniqId); $this->urlBuilderMock->expects($this->atLeastOnce())->method('getUrl')->with('cms/block_widget/chooser', ['uniq_id' => $uniqId])->willReturn($sourceUrl); $this->layoutMock->expects($this->atLeastOnce())->method('createBlock')->with('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->willReturn($this->chooserMock); $this->chooserMock->expects($this->atLeastOnce())->method('setElement')->with($this->elementMock)->willReturnSelf(); $this->chooserMock->expects($this->atLeastOnce())->method('setConfig')->with($config)->willReturnSelf(); $this->chooserMock->expects($this->atLeastOnce())->method('setFieldsetId')->with($fieldsetId)->willReturnSelf(); $this->chooserMock->expects($this->atLeastOnce())->method('setSourceUrl')->with($sourceUrl)->willReturnSelf(); $this->chooserMock->expects($this->atLeastOnce())->method('setUniqId')->with($uniqId)->willReturnSelf(); $this->elementMock->expects($this->atLeastOnce())->method('getValue')->willReturn($elementValue); $this->blockFactoryMock->expects($this->any())->method('create')->willReturn($this->modelBlockMock); $this->modelBlockMock->expects($this->any())->method('load')->with($elementValue)->willReturnSelf(); $this->modelBlockMock->expects($this->any())->method('getId')->willReturn($modelBlockId); $this->modelBlockMock->expects($this->any())->method('getTitle')->willReturn($title); $this->chooserMock->expects($this->atLeastOnce())->method('toHtml')->willReturn($html); if (!empty($elementValue) && !empty($modelBlockId)) { $this->escaper->expects($this->atLeastOnce())->method('escapeHtml')->willReturn($titleEscaped); $this->chooserMock->expects($this->atLeastOnce())->method('setLabel')->with($titleEscaped)->willReturnSelf(); } $this->elementMock->expects($this->atLeastOnce())->method('setData')->with('after_element_html', $html)->willReturnSelf(); $this->assertEquals($this->elementMock, $this->this->prepareElementHtml($this->elementMock)); }
/** * @param string $data * @param string $expected * @param null|array $allowedTags * @dataProvider escapeHtmlWithLinksDataProvider */ public function testEscapeHtmlWithLinks($data, $expected, $allowedTags = null) { $this->escaperMock ->expects($this->any()) ->method('escapeHtml') ->will($this->returnValue($expected)); $actual = $this->adminHelper->escapeHtmlWithLinks($data, $allowedTags); $this->assertEquals($expected, $actual); }
public function testRenderTitle() { $title = 'some_title'; $expected = "<title>some_title</title>" . "\n"; $this->pageConfigMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock); $this->titleMock->expects($this->once())->method('get')->willReturn($title); $this->escaperMock->expects($this->once())->method('escapeHtml')->willReturnArgument(0); $this->assertEquals($expected, $this->renderer->renderTitle()); }
/** * @param bool $isAjax * @return array * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function prepareExecuteWithQuantityArray($isAjax = false) { $itemId = 2; $wishlistId = 1; $qty = [$itemId => 3]; $productId = 4; $productName = 'product_name'; $indexUrl = 'index_url'; $configureUrl = 'configure_url'; $options = [5 => 'option']; $params = ['item' => $itemId, 'qty' => $qty]; $refererUrl = 'referer_url'; $itemMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item')->disableOriginalConstructor()->setMethods(['load', 'getId', 'getWishlistId', 'setQty', 'setOptions', 'getBuyRequest', 'mergeBuyRequest', 'addToCart', 'getProduct', 'getProductId'])->getMock(); $this->requestMock->expects($this->at(0))->method('getParam')->with('item', null)->willReturn($itemId); $this->itemFactoryMock->expects($this->once())->method('create')->willReturn($itemMock); $itemMock->expects($this->once())->method('load')->with($itemId, null)->willReturnSelf(); $itemMock->expects($this->exactly(2))->method('getId')->willReturn($itemId); $itemMock->expects($this->once())->method('getWishlistId')->willReturn($wishlistId); $wishlistMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Wishlist')->disableOriginalConstructor()->getMock(); $this->wishlistProviderMock->expects($this->once())->method('getWishlist')->with($wishlistId)->willReturn($wishlistMock); $this->requestMock->expects($this->at(1))->method('getParam')->with('qty', null)->willReturn($qty); $this->quantityProcessorMock->expects($this->once())->method('process')->with($qty[$itemId])->willReturnArgument(0); $itemMock->expects($this->once())->method('setQty')->with($qty[$itemId])->willReturnSelf(); $this->urlMock->expects($this->at(0))->method('getUrl')->with('*/*', null)->willReturn($indexUrl); $itemMock->expects($this->once())->method('getProductId')->willReturn($productId); $this->urlMock->expects($this->at(1))->method('getUrl')->with('*/*/configure/', ['id' => $itemId, 'product_id' => $productId])->willReturn($configureUrl); $optionMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item\\Option')->disableOriginalConstructor()->getMock(); $this->optionFactoryMock->expects($this->once())->method('create')->willReturn($optionMock); $optionsMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Resource\\Item\\Option\\Collection')->disableOriginalConstructor()->getMock(); $optionMock->expects($this->once())->method('getCollection')->willReturn($optionsMock); $optionsMock->expects($this->once())->method('addItemFilter')->with([$itemId])->willReturnSelf(); $optionsMock->expects($this->once())->method('getOptionsByItem')->with($itemId)->willReturn($options); $itemMock->expects($this->once())->method('setOptions')->with($options)->willReturnSelf(); $this->requestMock->expects($this->once())->method('getParams')->willReturn($params); $this->requestMock->expects($this->once())->method('isAjax')->willReturn($isAjax); $buyRequestMock = $this->getMockBuilder('Magento\\Framework\\Object')->disableOriginalConstructor()->getMock(); $itemMock->expects($this->once())->method('getBuyRequest')->willReturn($buyRequestMock); $this->productHelperMock->expects($this->once())->method('addParamsToBuyRequest')->with($params, ['current_config' => $buyRequestMock])->willReturn($buyRequestMock); $itemMock->expects($this->once())->method('mergeBuyRequest')->with($buyRequestMock)->willReturnSelf(); $itemMock->expects($this->once())->method('addToCart')->with($this->checkoutCartMock, true)->willReturn(true); $this->checkoutCartMock->expects($this->once())->method('save')->willReturnSelf(); $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods(['getHasError', 'collectTotals'])->getMock(); $this->checkoutCartMock->expects($this->exactly(2))->method('getQuote')->willReturn($quoteMock); $quoteMock->expects($this->once())->method('collectTotals')->willReturnSelf(); $wishlistMock->expects($this->once())->method('save')->willReturnSelf(); $quoteMock->expects($this->once())->method('getHasError')->willReturn(false); $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock(); $itemMock->expects($this->once())->method('getProduct')->willReturn($productMock); $productMock->expects($this->once())->method('getName')->willReturn($productName); $this->escaperMock->expects($this->once())->method('escapeHtml')->with($productName, null)->willReturn($productName); $this->messageManagerMock->expects($this->once())->method('addSuccess')->with('You added ' . $productName . ' to your shopping cart.', null)->willReturnSelf(); $this->cartHelperMock->expects($this->once())->method('getShouldRedirectToCart')->willReturn(false); $this->redirectMock->expects($this->once())->method('getRefererUrl')->willReturn($refererUrl); $this->helperMock->expects($this->once())->method('calculate')->willReturnSelf(); return $refererUrl; }
public function testToOptionArray() { $websiteCollection = [$this->websiteMock]; $groupCollection = [$this->groupMock]; $storeCollection = [$this->storeMock]; $expectedOptions = [['label' => __('All Store Views'), 'value' => '0'], ['label' => 'Main Website', 'value' => [['label' => ' Main Website Store', 'value' => [['label' => ' Default Store View', 'value' => '1']]]]]]; $this->systemStoreMock->expects($this->once())->method('getWebsiteCollection')->willReturn($websiteCollection); $this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn($groupCollection); $this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn($storeCollection); $this->websiteMock->expects($this->atLeastOnce())->method('getId')->willReturn('1'); $this->websiteMock->expects($this->any())->method('getName')->willReturn('Main Website'); $this->groupMock->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn('1'); $this->groupMock->expects($this->atLeastOnce())->method('getId')->willReturn('1'); $this->groupMock->expects($this->atLeastOnce())->method('getName')->willReturn('Main Website Store'); $this->storeMock->expects($this->atLeastOnce())->method('getGroupId')->willReturn('1'); $this->storeMock->expects($this->atLeastOnce())->method('getName')->willReturn('Default Store View'); $this->storeMock->expects($this->atLeastOnce())->method('getId')->willReturn('1'); $this->escaperMock->expects($this->atLeastOnce())->method('escapeHtml')->willReturnMap([['Default Store View', null, 'Default Store View'], ['Main Website Store', null, 'Main Website Store'], ['Main Website', null, 'Main Website']]); $this->assertEquals($expectedOptions, $this->options->toOptionArray()); }
/** * @covers \Magento\Cms\Helper\Page::renderPageExtended * @param integer|null $pageId * @param integer|null $internalPageId * @param integer $pageLoadResultIndex * @param string $customPageLayout * @param string $handle * @param string $customLayoutUpdateXml * @param string $layoutUpdate * @param boolean $expectedResult * * @dataProvider renderPageExtendedDataProvider * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testRenderPageExtended($pageId, $internalPageId, $pageLoadResultIndex, $customPageLayout, $handle, $customLayoutUpdateXml, $layoutUpdate, $expectedResult) { $storeId = 321; $customThemeFrom = 'customThemeFrom'; $customThemeTo = 'customThemeTo'; $isScopeDateInInterval = true; $customTheme = 'customTheme'; $pageLayout = 'pageLayout'; $pageIdentifier = 111; $layoutUpdateXml = 'layoutUpdateXml'; $contentHeading = 'contentHeading'; $escapedContentHeading = 'escapedContentHeading'; $defaultGroup = 'defaultGroup'; $pageLoadResultCollection = [null, $this->pageMock]; $this->pageMock->expects($this->any())->method('getId')->willReturn($internalPageId); $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock); $this->storeMock->expects($this->any())->method('getId')->willReturn($storeId); $this->pageMock->expects($this->any())->method('setStoreId')->with($storeId)->willReturnSelf(); $this->pageMock->expects($this->any())->method('load')->with($pageId)->willReturn($pageLoadResultCollection[$pageLoadResultIndex]); $this->pageMock->expects($this->any())->method('getCustomThemeFrom')->willReturn($customThemeFrom); $this->pageMock->expects($this->any())->method('getCustomThemeTo')->willReturn($customThemeTo); $this->localeDateMock->expects($this->any())->method('isScopeDateInInterval')->with(null, $customThemeFrom, $customThemeTo)->willReturn($isScopeDateInInterval); $this->pageMock->expects($this->any())->method('getCustomTheme')->willReturn($customTheme); $this->designMock->expects($this->any())->method('setDesignTheme')->with($customTheme)->willReturnSelf(); $this->pageMock->expects($this->any())->method('getPageLayout')->willReturn($pageLayout); $this->pageMock->expects($this->any())->method('getCustomPageLayout')->willReturn($customPageLayout); $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock); $this->pageConfigMock->expects($this->any())->method('setPageLayout')->with($handle)->willReturnSelf(); $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->resultPageMock); $this->resultPageMock->expects($this->any())->method('initLayout')->willReturnSelf(); $this->resultPageMock->expects($this->any())->method('getLayout')->willReturn($this->layoutMock); $this->layoutMock->expects($this->any())->method('getUpdate')->willReturn($this->layoutProcessorMock); $this->layoutProcessorMock->expects($this->any())->method('addHandle')->with('cms_page_view')->willReturnSelf(); $this->pageMock->expects($this->any())->method('getIdentifier')->willReturn($pageIdentifier); $this->viewMock->expects($this->any())->method('addPageLayoutHandles')->with(['id' => $pageIdentifier])->willReturn(true); $this->eventManagerMock->expects($this->any())->method('dispatch')->with('cms_page_render', ['page' => $this->pageMock, 'controller_action' => $this->actionMock]); $this->viewMock->expects($this->any())->method('loadLayoutUpdates')->willReturnSelf(); $this->pageMock->expects($this->any())->method('getCustomLayoutUpdateXml')->willReturn($customLayoutUpdateXml); $this->pageMock->expects($this->any())->method('getLayoutUpdateXml')->willReturn($layoutUpdateXml); $this->layoutProcessorMock->expects($this->any())->method('addUpdate')->with($layoutUpdate)->willReturnSelf(); $this->viewMock->expects($this->any())->method('generateLayoutXml')->willReturnSelf(); $this->viewMock->expects($this->any())->method('generateLayoutBlocks')->willReturnSelf(); $this->layoutMock->expects($this->any())->method('getBlock')->with('page_content_heading')->willReturn($this->blockMock); $this->pageMock->expects($this->any())->method('getContentHeading')->willReturn($contentHeading); $this->escaperMock->expects($this->any())->method('escapeHtml')->with($contentHeading)->willReturn($escapedContentHeading); $this->blockMock->expects($this->any())->method('setContentHeading')->with($escapedContentHeading)->willReturnSelf(); $this->layoutMock->expects($this->any())->method('getMessagesBlock')->willReturn($this->messagesBlockMock); $this->messageManagerMock->expects($this->any())->method('getDefaultGroup')->willReturn($defaultGroup); $this->messagesBlockMock->expects($this->any())->method('addStorageType')->with($defaultGroup); $this->messageManagerMock->expects($this->any())->method('getMessages')->with(true)->willReturn($this->messageCollectionMock); $this->messagesBlockMock->expects($this->any())->method('addMessages')->with($this->messageCollectionMock)->willReturnSelf(); $this->viewMock->expects($this->any())->method('renderLayout')->willReturnSelf(); $this->assertEquals($expectedResult, $this->object->renderPageExtended($this->actionMock, $pageId)); }
public function testExecute() { $formKey = 'form_key'; $escapedFormKey = 'escaped_form_key'; $cookieDomain = 'example.com'; $cookiePath = '/'; $cookieLifetime = 3600; $cookieMetadata = $this->getMockBuilder('Magento\\Framework\\Stdlib\\Cookie\\PublicCookieMetadata')->disableOriginalConstructor()->getMock(); $this->cookieFormKey->expects(static::any())->method('get')->willReturn($formKey); $this->cookieMetadataFactory->expects(static::once())->method('createPublicCookieMetadata')->willReturn($cookieMetadata); $this->sessionConfig->expects(static::once())->method('getCookieDomain')->willReturn($cookieDomain); $cookieMetadata->expects(static::once())->method('setDomain')->with($cookieDomain); $this->sessionConfig->expects(static::once())->method('getCookiePath')->willReturn($cookiePath); $cookieMetadata->expects(static::once())->method('setPath')->with($cookiePath); $this->sessionConfig->expects(static::once())->method('getCookieLifetime')->willReturn($cookieLifetime); $cookieMetadata->expects(static::once())->method('setDuration')->with($cookieLifetime); $this->cookieFormKey->expects(static::once())->method('set')->with($formKey, $cookieMetadata); $this->escaper->expects(static::once())->method('escapeHtml')->with($formKey)->willReturn($escapedFormKey); $this->sessionFormKey->expects(static::once())->method('set')->with($escapedFormKey); $this->observer->execute($this->observerMock); }
/** * @covers \Magento\Cms\Helper\Page::prepareResultPage * @param integer|null $pageId * @param integer|null $internalPageId * @param integer $pageLoadResultIndex * @param string $customPageLayout * @param string $handle * @param string $customLayoutUpdateXml * @param string $layoutUpdate * @param boolean $expectedResult * * @dataProvider renderPageExtendedDataProvider * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testPrepareResultPage($pageId, $internalPageId, $pageLoadResultIndex, $customPageLayout, $handle, $customLayoutUpdateXml, $layoutUpdate, $expectedResult) { $storeId = 321; $customThemeFrom = 'customThemeFrom'; $customThemeTo = 'customThemeTo'; $isScopeDateInInterval = true; $customTheme = 'customTheme'; $pageLayout = 'pageLayout'; $pageIdentifier = 111; $layoutUpdateXml = 'layoutUpdateXml'; $contentHeading = 'contentHeading'; $escapedContentHeading = 'escapedContentHeading'; $pageLoadResultCollection = [null, $this->pageMock]; $this->pageMock->expects($this->any())->method('getId')->willReturn($internalPageId); $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock); $this->storeMock->expects($this->any())->method('getId')->willReturn($storeId); $this->pageMock->expects($this->any())->method('setStoreId')->with($storeId)->willReturnSelf(); $this->pageMock->expects($this->any())->method('load')->with($pageId)->willReturn($pageLoadResultCollection[$pageLoadResultIndex]); $this->pageMock->expects($this->any())->method('getCustomThemeFrom')->willReturn($customThemeFrom); $this->pageMock->expects($this->any())->method('getCustomThemeTo')->willReturn($customThemeTo); $this->localeDateMock->expects($this->any())->method('isScopeDateInInterval')->with(null, $customThemeFrom, $customThemeTo)->willReturn($isScopeDateInInterval); $this->pageMock->expects($this->any())->method('getCustomTheme')->willReturn($customTheme); $this->designMock->expects($this->any())->method('setDesignTheme')->with($customTheme)->willReturnSelf(); $this->pageMock->expects($this->any())->method('getPageLayout')->willReturn($pageLayout); $this->pageMock->expects($this->any())->method('getCustomPageLayout')->willReturn($customPageLayout); $this->resultPageFactory->expects($this->any())->method('create')->will($this->returnValue($this->resultPageMock)); $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock); $this->pageConfigMock->expects($this->any())->method('setPageLayout')->with($handle)->willReturnSelf(); $this->resultPageMock->expects($this->any())->method('initLayout')->willReturnSelf(); $this->resultPageMock->expects($this->any())->method('getLayout')->willReturn($this->layoutMock); $this->layoutMock->expects($this->any())->method('getUpdate')->willReturn($this->layoutProcessorMock); $this->layoutProcessorMock->expects($this->any())->method('addHandle')->with('cms_page_view')->willReturnSelf(); $this->pageMock->expects($this->any())->method('getIdentifier')->willReturn($pageIdentifier); $this->eventManagerMock->expects($this->any())->method('dispatch')->with('cms_page_render', ['page' => $this->pageMock, 'controller_action' => $this->actionMock]); $this->pageMock->expects($this->any())->method('getCustomLayoutUpdateXml')->willReturn($customLayoutUpdateXml); $this->pageMock->expects($this->any())->method('getLayoutUpdateXml')->willReturn($layoutUpdateXml); $this->layoutProcessorMock->expects($this->any())->method('addUpdate')->with($layoutUpdate)->willReturnSelf(); $this->layoutMock->expects($this->any())->method('getBlock')->with('page_content_heading')->willReturn($this->blockMock); $this->pageMock->expects($this->any())->method('getContentHeading')->willReturn($contentHeading); $this->escaperMock->expects($this->any())->method('escapeHtml')->with($contentHeading)->willReturn($escapedContentHeading); $this->blockMock->expects($this->any())->method('setContentHeading')->with($escapedContentHeading)->willReturnSelf(); if ($expectedResult) { $expectedResult = $this->resultPageMock; } $this->assertSame($expectedResult, $this->object->prepareResultPage($this->actionMock, $pageId)); }
/** * @param string $actionName * @return \Magento\Integration\Controller\Adminhtml\Integration * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _createIntegrationController($actionName) { // Mock Layout passed into constructor $this->_viewMock = $this->getMockBuilder('Magento\\Framework\\App\\ViewInterface')->getMock(); $this->_layoutMock = $this->getMock('Magento\\Framework\\View\\LayoutInterface'); $this->_layoutMergeMock = $this->getMockBuilder('Magento\\Framework\\View\\Model\\Layout\\Merge')->disableOriginalConstructor()->getMock(); $this->_layoutMock->expects($this->any())->method('getUpdate')->will($this->returnValue($this->_layoutMergeMock)); $testElement = new \Magento\Framework\Simplexml\Element('<test>test</test>'); $this->_layoutMock->expects($this->any())->method('getNode')->will($this->returnValue($testElement)); // for _setActiveMenu $this->_viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->_layoutMock)); $blockMock = $this->getMockBuilder('Magento\\Backend\\Block\\Menu')->disableOriginalConstructor()->getMock(); $menuMock = $this->getMock('Magento\\Backend\\Model\\Menu', [], [$this->getMock('Psr\\Log\\LoggerInterface')]); $loggerMock = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $loggerMock->expects($this->any())->method('critical')->will($this->returnSelf()); $menuMock->expects($this->any())->method('getParentItems')->will($this->returnValue([])); $blockMock->expects($this->any())->method('getMenuModel')->will($this->returnValue($menuMock)); $this->_layoutMock->expects($this->any())->method('getMessagesBlock')->will($this->returnValue($blockMock)); $this->_layoutMock->expects($this->any())->method('getBlock')->will($this->returnValue($blockMock)); $this->_viewMock->expects($this->any())->method('getPage')->willReturn($this->resultPageMock); $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->viewConfigMock); $this->viewConfigMock->expects($this->any())->method('getTitle')->willReturn($this->pageTitleMock); $this->_escaper->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0)); $this->resultRedirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $this->resultFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $this->_authMock->expects($this->any())->method('getUser')->will($this->returnValue($this->_userMock)); $this->_userMock->expects($this->any())->method('load')->willReturn($this->_userMock); $this->_backendSessionMock->expects($this->any())->method('getIntegrationData')->willReturn(['all_resources' => 1]); $contextParameters = ['view' => $this->_viewMock, 'objectManager' => $this->_objectManagerMock, 'session' => $this->_backendSessionMock, 'translator' => $this->_translateModelMock, 'request' => $this->_requestMock, 'response' => $this->_responseMock, 'messageManager' => $this->_messageManager, 'resultRedirectFactory' => $this->resultRedirectFactory, 'resultFactory' => $this->resultFactory, 'auth' => $this->_authMock, 'eventManager' => $this->_eventManagerMock]; $this->_backendActionCtxMock = $this->_objectManagerHelper->getObject('Magento\\Backend\\App\\Action\\Context', $contextParameters); $integrationCollection = $this->getMockBuilder('\\Magento\\Integration\\Model\\ResourceModel\\Integration\\Collection')->disableOriginalConstructor()->setMethods(['addUnsecureUrlsFilter', 'getSize'])->getMock(); $integrationCollection->expects($this->any())->method('addUnsecureUrlsFilter')->will($this->returnValue($integrationCollection)); $integrationCollection->expects($this->any())->method('getSize')->will($this->returnValue(0)); $subControllerParams = ['context' => $this->_backendActionCtxMock, 'integrationService' => $this->_integrationSvcMock, 'oauthService' => $this->_oauthSvcMock, 'registry' => $this->_registryMock, 'logger' => $loggerMock, 'integrationData' => $this->_integrationHelperMock, 'escaper' => $this->_escaper, 'integrationCollection' => $integrationCollection]; /** Create IntegrationController to test */ $controller = $this->_objectManagerHelper->getObject('\\Magento\\Integration\\Controller\\Adminhtml\\Integration\\' . $actionName, $subControllerParams); if ($actionName == 'Save') { $reflection = new \ReflectionClass(get_class($controller)); $reflectionProperty = $reflection->getProperty('securityCookie'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($controller, $this->securityCookieMock); } return $controller; }
public function testGetOptions() { $optionIds = 'a:1:{i:0;i:1;}'; $selectionIds = 'a:1:{i:0;s:1:"2";}'; $selectionId = '2'; $product = $this->getMock('Magento\\Catalog\\Model\\Product', ['getTypeInstance', '__wakeup', 'getCustomOption', 'getSelectionId', 'getName', 'getPriceModel'], [], '', false); $typeInstance = $this->getMock('Magento\\Bundle\\Model\\Product\\Type', ['getOptionsByIds', 'getSelectionsByIds'], [], '', false); $priceModel = $this->getMock('Magento\\Bundle\\Model\\Product\\Price', ['getSelectionFinalTotalPrice'], [], '', false); $selectionQty = $this->getMock('Magento\\Quote\\Model\\Quote\\Item\\Option', ['getValue', '__wakeup'], [], '', false); $bundleOption = $this->getMock('Magento\\Bundle\\Model\\Option', ['getSelections', 'getTitle', '__wakeup'], [], '', false); $selectionOption = $this->getMock('\\Magento\\Catalog\\Model\\Product\\Configuration\\Item\\Option\\OptionInterface', ['getValue']); $collection = $this->getMock('Magento\\Bundle\\Model\\ResourceModel\\Option\\Collection', ['appendSelections'], [], '', false); $itemOption = $this->getMock('\\Magento\\Catalog\\Model\\Product\\Configuration\\Item\\Option\\OptionInterface', ['getValue']); $collection2 = $this->getMock('Magento\\Bundle\\Model\\ResourceModel\\Selection\\Collection', [], [], '', false); $this->escaper->expects($this->once())->method('escapeHtml')->with('name')->will($this->returnValue('name')); $this->pricingHelper->expects($this->once())->method('currency')->with(15)->will($this->returnValue('<span class="price">$15.00</span>')); $priceModel->expects($this->once())->method('getSelectionFinalTotalPrice')->will($this->returnValue(15)); $selectionQty->expects($this->any())->method('getValue')->will($this->returnValue(1)); $bundleOption->expects($this->any())->method('getSelections')->will($this->returnValue([$product])); $bundleOption->expects($this->once())->method('getTitle')->will($this->returnValue('title')); $selectionOption->expects($this->once())->method('getValue')->will($this->returnValue($selectionIds)); $collection->expects($this->once())->method('appendSelections')->with($collection2, true)->will($this->returnValue([$bundleOption])); $itemOption->expects($this->once())->method('getValue')->will($this->returnValue($optionIds)); $typeInstance->expects($this->once())->method('getOptionsByIds')->with(unserialize($optionIds), $product)->will($this->returnValue($collection)); $typeInstance->expects($this->once())->method('getSelectionsByIds')->with(unserialize($selectionIds), $product)->will($this->returnValue($collection2)); $product->expects($this->once())->method('getTypeInstance')->will($this->returnValue($typeInstance)); $product->expects($this->any())->method('getCustomOption')->with('selection_qty_' . $selectionId)->will($this->returnValue($selectionQty)); $product->expects($this->any())->method('getSelectionId')->will($this->returnValue($selectionId)); $product->expects($this->once())->method('getName')->will($this->returnValue('name')); $product->expects($this->once())->method('getPriceModel')->will($this->returnValue($priceModel)); $this->item->expects($this->any())->method('getProduct')->will($this->returnValue($product)); $this->item->expects($this->at(1))->method('getOptionByCode')->with('bundle_option_ids')->will($this->returnValue($itemOption)); $this->item->expects($this->at(2))->method('getOptionByCode')->with('bundle_selection_ids')->will($this->returnValue($selectionOption)); $this->productConfiguration->expects($this->once())->method('getCustomOptions')->with($this->item)->will($this->returnValue([0 => ['label' => 'title', 'value' => 'value']])); $this->assertEquals([0 => ['label' => 'title', 'value' => [0 => '1 x name <span class="price">$15.00</span>']], 1 => ['label' => 'title', 'value' => 'value']], $this->helper->getOptions($this->item)); }