File tree Expand file tree Collapse file tree 3 files changed +51
-5
lines changed
Block/Adminhtml/Order/Create
Test/Unit/Block/Adminhtml/Order/Create Expand file tree Collapse file tree 3 files changed +51
-5
lines changed Original file line number Diff line number Diff line change @@ -160,4 +160,22 @@ public function convertPrice($value, $format = true)
160
160
)
161
161
: $ this ->priceCurrency ->convert ($ value , $ this ->getStore ());
162
162
}
163
+
164
+ /**
165
+ * If item is quote or wishlist we need to get product from it.
166
+ *
167
+ * @param $item
168
+ *
169
+ * @return Product
170
+ */
171
+ public function getProduct ($ item )
172
+ {
173
+ if ($ item instanceof Product) {
174
+ $ product = $ item ;
175
+ } else {
176
+ $ product = $ item ->getProduct ();
177
+ }
178
+
179
+ return $ product ;
180
+ }
163
181
}
Original file line number Diff line number Diff line change 3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Sales \Test \Unit \Block \Adminhtml \Order \Create ;
7
8
9
+ use Magento \Catalog \Model \Product ;
8
10
use Magento \Catalog \Pricing \Price \FinalPrice ;
9
11
10
12
class AbstractCreateTest extends \PHPUnit \Framework \TestCase
@@ -67,4 +69,34 @@ public function testGetItemPrice()
67
69
->willReturn ($ resultPrice );
68
70
$ this ->assertEquals ($ resultPrice , $ this ->model ->getItemPrice ($ this ->productMock ));
69
71
}
72
+
73
+ /**
74
+ * @param $item
75
+ *
76
+ * @dataProvider getProductDataProvider
77
+ */
78
+ public function testGetProduct ($ item )
79
+ {
80
+ $ product = $ this ->model ->getProduct ($ item );
81
+
82
+ self ::assertInstanceOf (Product::class, $ product );
83
+ }
84
+
85
+ /**
86
+ * DataProvider for testGetProduct.
87
+ *
88
+ * @return array
89
+ */
90
+ public function getProductDataProvider ()
91
+ {
92
+ $ productMock = $ this ->createMock (Product::class);
93
+
94
+ $ itemMock = $ this ->createMock (\Magento \Wishlist \Model \Item::class);
95
+ $ itemMock ->expects ($ this ->once ())->method ('getProduct ' )->willReturn ($ productMock );
96
+
97
+ return [
98
+ [$ productMock ],
99
+ [$ itemMock ],
100
+ ];
101
+ }
70
102
}
Original file line number Diff line number Diff line change 67
67
68
68
<?php if ($ block ->canDisplayPrice ()): ?>
69
69
<td class="col-price">
70
- <?php if ($ block ->getDataId () == 'cart ' ): ?>
71
- <?= /* @noEscape */ $ block ->getItemPrice ($ _item ->getProduct ()) ?>
72
- <?php else : ?>
73
- <?= /* @noEscape */ $ block ->getItemPrice ($ _item ) ?>
74
- <?php endif ; ?>
70
+ <?= /* @noEscape */ $ block ->getItemPrice ($ block ->getProduct ($ _item )) ?>
75
71
</td>
76
72
<?php endif ; ?>
77
73
You can’t perform that action at this time.
0 commit comments