6
6
7
7
namespace Magento \Multishipping \Block \Checkout ;
8
8
9
+ use Magento \Catalog \Model \ProductRepository ;
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
+
9
21
/**
10
- * @magentoDataFixture Magento/Catalog/_files/product_simple.php
22
+ * Verify default items template
11
23
*/
12
- class OverviewTest extends \ PHPUnit \ Framework \ TestCase
24
+ class OverviewTest extends TestCase
13
25
{
14
26
/**
15
- * @var \Magento\Multishipping\Block\Checkout\Overview
27
+ * @var Overview
28
+ */
29
+ private $ block ;
30
+
31
+ /**
32
+ * @var ObjectManagerInterface
33
+ */
34
+ private $ objectManager ;
35
+
36
+ /**
37
+ * @var Quote
38
+ */
39
+ private $ quote ;
40
+
41
+ /**
42
+ * @var ProductRepository
16
43
*/
17
- protected $ _block ;
44
+ private $ product ;
18
45
19
46
/**
20
- * @var \Magento\Framework\ObjectManagerInterface
47
+ * @var Item
21
48
*/
22
- protected $ _objectManager ;
49
+ private $ item ;
23
50
51
+ /**
52
+ * @inheritdoc
53
+ */
24
54
protected function setUp (): void
25
55
{
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)
56
+ Bootstrap::getInstance ()->loadArea (Area::AREA_FRONTEND );
57
+ $ this ->objectManager = Bootstrap::getObjectManager ();
58
+ $ this ->block = $ this ->objectManager ->get (LayoutInterface::class)
29
59
->createBlock (
30
- \ Magento \ Multishipping \ Block \ Checkout \ Overview::class,
60
+ Overview::class,
31
61
'checkout_overview ' ,
32
62
[
33
63
'data ' => [
@@ -37,33 +67,49 @@ protected function setUp(): void
37
67
]
38
68
);
39
69
40
- $ this ->_block ->addChild ('renderer.list ' , \ Magento \ Framework \ View \ Element \ RendererList::class);
41
- $ this ->_block ->getChildBlock (
70
+ $ this ->block ->addChild ('renderer.list ' , RendererList::class);
71
+ $ this ->block ->getChildBlock (
42
72
'renderer.list '
43
73
)->addChild (
44
74
'default ' ,
45
- \ Magento \ Checkout \ Block \ Cart \ Item \ Renderer::class,
75
+ Renderer::class,
46
76
['template ' => 'cart/item/default.phtml ' ]
47
77
);
78
+ $ this ->quote = $ this ->objectManager ->create (Quote::class);
79
+ $ this ->product = $ this ->objectManager ->create (ProductRepository::class);
80
+ $ this ->item = $ this ->objectManager ->create (Item::class);
48
81
}
49
82
83
+ /**
84
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
85
+ */
50
86
public function testGetRowItemHtml ()
51
87
{
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 );
88
+ $ product = $ this ->product ->get ('simple ' );
89
+ $ item = $ this ->item ->setProduct ($ product );
90
+ $ item ->setQuote ($ this ->quote );
61
91
// assure that default renderer was obtained
62
92
$ this ->assertEquals (
63
93
1 ,
64
- \ Magento \ TestFramework \ Helper \ Xpath::getElementsCountForXpath (
94
+ Xpath::getElementsCountForXpath (
65
95
'//*[contains(@class,"product") and contains(@class,"name")]/a ' ,
66
- $ this ->_block ->getRowItemHtml ($ item )
96
+ $ this ->block ->getRowItemHtml ($ item )
97
+ )
98
+ );
99
+ }
100
+
101
+ /**
102
+ * @magentoDataFixture Magento/Checkout/_files/customer_quote_with_items_simple_product_options.php
103
+ */
104
+ public function testLinkOptionalProductFileItemHtml ()
105
+ {
106
+ $ quote = $ this ->quote ->load ('customer_quote_product_custom_options ' , 'reserved_order_id ' );
107
+ $ item = current ($ quote ->getAllItems ());
108
+ $ this ->assertEquals (
109
+ 1 ,
110
+ Xpath::getElementsCountForXpath (
111
+ '//dd/a[contains(text(), "test.jpg")] ' ,
112
+ $ this ->block ->getRowItemHtml ($ item )
67
113
)
68
114
);
69
115
}
0 commit comments