6
6
7
7
namespace Magento \Multishipping \Block \Checkout ;
8
8
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
+
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
+ protected $ block ;
30
+
31
+ /**
32
+ * @var ObjectManagerInterface
16
33
*/
17
- protected $ _block ;
34
+ protected $ objectManager ;
18
35
19
36
/**
20
- * @var \Magento\Framework\ObjectManagerInterface
37
+ * @var Quote
21
38
*/
22
- protected $ _objectManager ;
39
+ private $ quote ;
40
+
41
+ /**
42
+ * @var Product
43
+ */
44
+ private $ product ;
45
+
46
+ /**
47
+ * @var Item
48
+ */
49
+ private $ item ;
23
50
24
51
protected function setUp (): void
25
52
{
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)
29
56
->createBlock (
30
- \ Magento \ Multishipping \ Block \ Checkout \ Overview::class,
57
+ Overview::class,
31
58
'checkout_overview ' ,
32
59
[
33
60
'data ' => [
@@ -37,33 +64,49 @@ protected function setUp(): void
37
64
]
38
65
);
39
66
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 (
42
69
'renderer.list '
43
70
)->addChild (
44
71
'default ' ,
45
- \ Magento \ Checkout \ Block \ Cart \ Item \ Renderer::class,
72
+ Renderer::class,
46
73
['template ' => 'cart/item/default.phtml ' ]
47
74
);
75
+ $ this ->quote = $ this ->objectManager ->get (Quote::class);
76
+ $ this ->product = $ this ->objectManager ->get (Product::class);
77
+ $ this ->item = $ this ->objectManager ->get (Item::class);
48
78
}
49
79
80
+ /**
81
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
82
+ */
50
83
public function testGetRowItemHtml ()
51
84
{
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 );
61
88
// assure that default renderer was obtained
62
89
$ this ->assertEquals (
63
90
1 ,
64
- \ Magento \ TestFramework \ Helper \ Xpath::getElementsCountForXpath (
91
+ Xpath::getElementsCountForXpath (
65
92
'//*[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 )
67
110
)
68
111
);
69
112
}
0 commit comments