Skip to content

Commit 9bd13e4

Browse files
committed
MC-37807: Link to a file of a Product with Customizable Option(File) is not available throughout a multishipping checkout process
1 parent f13958e commit 9bd13e4

File tree

2 files changed

+77
-29
lines changed
  • app/code/Magento/Multishipping/view/frontend/templates/checkout/item
  • dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout

2 files changed

+77
-29
lines changed

app/code/Magento/Multishipping/view/frontend/templates/checkout/item/default.phtml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,23 @@
66

77
// phpcs:disable Magento2.Files.LineLength
88
?>
9-
<strong class="product name product-item-name"><a href="<?= $block->escapeUrl($block->getProductUrl()) ?>"><?= $block->escapeHtml($block->getProductName()) ?></a></strong>
9+
<?php
10+
/** @var \Magento\Checkout\Block\Cart\Item\Renderer\ $block */
11+
/** @var \Magento\Framework\Escaper $escaper */
12+
?>
13+
14+
<strong class="product name product-item-name"><a href="<?= $escaper->escapeUrl($block->getProductUrl()) ?>"><?= $escaper->escapeHtml($block->getProductName()) ?></a></strong>
1015
<?php if ($_options = $block->getOptionList()) : ?>
1116
<dl class="item-options">
1217
<?php foreach ($_options as $_option) : ?>
1318
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
14-
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
19+
<dt><?= $escaper->escapeHtml($_option['label']) ?></dt>
1520
<dd<?= (isset($_formatedOptionValue['full_view']) ? ' class="tooltip wrapper"' : '') ?>>
16-
<?= $block->escapeHtml($_formatedOptionValue['value'], ['span', 'a']) ?>
21+
<?= $escaper->escapeHtml($_formatedOptionValue['value'], ['span', 'a']) ?>
1722
<?php if (isset($_formatedOptionValue['full_view'])) : ?>
1823
<dl class="item options tooltip content">
19-
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
20-
<dd><?= $block->escapeHtml($_formatedOptionValue['full_view'], ['span']) ?></dd>
24+
<dt><?= $escaper->escapeHtml($_option['label']) ?></dt>
25+
<dd><?= $escaper->escapeHtml($_formatedOptionValue['full_view'], ['span']) ?></dd>
2126
</dl>
2227
<?php endif; ?>
2328
</dd>

dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php

Lines changed: 67 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,55 @@
66

77
namespace Magento\Multishipping\Block\Checkout;
88

9+
use Magento\Catalog\Model\Product;
10+
use Magento\Checkout\Block\Cart\Item\Renderer;
11+
use Magento\Framework\App\Area;
12+
use Magento\Framework\ObjectManagerInterface;
13+
use Magento\Framework\View\Element\RendererList;
14+
use Magento\Framework\View\LayoutInterface;
15+
use Magento\Quote\Model\Quote;
16+
use Magento\Quote\Model\Quote\Item;
17+
use Magento\TestFramework\Helper\Bootstrap;
18+
use Magento\TestFramework\Helper\Xpath;
19+
use PHPUnit\Framework\TestCase;
20+
921
/**
10-
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
22+
* Verify default items template
1123
*/
12-
class OverviewTest extends \PHPUnit\Framework\TestCase
24+
class OverviewTest extends TestCase
1325
{
1426
/**
15-
* @var \Magento\Multishipping\Block\Checkout\Overview
27+
* @var Overview
28+
*/
29+
protected $block;
30+
31+
/**
32+
* @var ObjectManagerInterface
1633
*/
17-
protected $_block;
34+
protected $objectManager;
1835

1936
/**
20-
* @var \Magento\Framework\ObjectManagerInterface
37+
* @var Quote
2138
*/
22-
protected $_objectManager;
39+
private $quote;
40+
41+
/**
42+
* @var Product
43+
*/
44+
private $product;
45+
46+
/**
47+
* @var Item
48+
*/
49+
private $item;
2350

2451
protected function setUp(): void
2552
{
26-
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND);
27-
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
28-
$this->_block = $this->_objectManager->get(\Magento\Framework\View\LayoutInterface::class)
53+
Bootstrap::getInstance()->loadArea(Area::AREA_FRONTEND);
54+
$this->objectManager = Bootstrap::getObjectManager();
55+
$this->block = $this->objectManager->get(LayoutInterface::class)
2956
->createBlock(
30-
\Magento\Multishipping\Block\Checkout\Overview::class,
57+
Overview::class,
3158
'checkout_overview',
3259
[
3360
'data' => [
@@ -37,33 +64,49 @@ protected function setUp(): void
3764
]
3865
);
3966

40-
$this->_block->addChild('renderer.list', \Magento\Framework\View\Element\RendererList::class);
41-
$this->_block->getChildBlock(
67+
$this->block->addChild('renderer.list', RendererList::class);
68+
$this->block->getChildBlock(
4269
'renderer.list'
4370
)->addChild(
4471
'default',
45-
\Magento\Checkout\Block\Cart\Item\Renderer::class,
72+
Renderer::class,
4673
['template' => 'cart/item/default.phtml']
4774
);
75+
$this->quote = $this->objectManager->get(Quote::class);
76+
$this->product = $this->objectManager->get(Product::class);
77+
$this->item = $this->objectManager->get(Item::class);
4878
}
4979

80+
/**
81+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
82+
*/
5083
public function testGetRowItemHtml()
5184
{
52-
/** @var $item \Magento\Quote\Model\Quote\Item */
53-
$item = $this->_objectManager->create(\Magento\Quote\Model\Quote\Item::class);
54-
/** @var $product \Magento\Catalog\Model\Product */
55-
$product = $this->_objectManager->create(\Magento\Catalog\Model\Product::class);
56-
$product->load(1);
57-
$item->setProduct($product);
58-
/** @var $quote \Magento\Quote\Model\Quote */
59-
$quote = $this->_objectManager->create(\Magento\Quote\Model\Quote::class);
60-
$item->setQuote($quote);
85+
$product = $this->product->load('1');
86+
$item = $this->item->setProduct($product);
87+
$item->setQuote($this->quote);
6188
// assure that default renderer was obtained
6289
$this->assertEquals(
6390
1,
64-
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
91+
Xpath::getElementsCountForXpath(
6592
'//*[contains(@class,"product") and contains(@class,"name")]/a',
66-
$this->_block->getRowItemHtml($item)
93+
$this->block->getRowItemHtml($item)
94+
)
95+
);
96+
}
97+
98+
/**
99+
* @magentoDataFixture Magento/Checkout/_files/customer_quote_with_items_simple_product_options.php
100+
*/
101+
public function testLinkOptionalProductFileItemHtml()
102+
{
103+
$quote = $this->quote->load('customer_quote_product_custom_options', 'reserved_order_id');
104+
$item = current($quote->getAllItems());
105+
$this->assertEquals(
106+
1,
107+
Xpath::getElementsCountForXpath(
108+
'//dd/a[contains(text(), "test.jpg")]',
109+
$this->block->getRowItemHtml($item)
67110
)
68111
);
69112
}

0 commit comments

Comments
 (0)