File tree 2 files changed +20
-2
lines changed
Test/Unit/Model/Product/Option
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 8
8
9
9
namespace Magento \Catalog \Model \Product \Option ;
10
10
11
+ use Magento \Catalog \Pricing \Price \BasePrice ;
11
12
use Magento \Framework \Model \AbstractModel ;
12
13
use Magento \Catalog \Model \Product ;
13
14
use Magento \Catalog \Model \Product \Option ;
@@ -225,7 +226,7 @@ public function saveValues()
225
226
public function getPrice ($ flag = false )
226
227
{
227
228
if ($ flag && $ this ->getPriceType () == self ::TYPE_PERCENT ) {
228
- $ basePrice = $ this ->getOption ()->getProduct ()->getFinalPrice ();
229
+ $ basePrice = $ this ->getOption ()->getProduct ()->getPriceInfo ()-> getPrice (BasePrice:: PRICE_CODE )-> getValue ();
229
230
$ price = $ basePrice * ($ this ->_getData (self ::KEY_PRICE ) / 100 );
230
231
return $ price ;
231
232
}
Original file line number Diff line number Diff line change @@ -170,13 +170,30 @@ private function getMockedOption()
170
170
private function getMockedProduct ()
171
171
{
172
172
$ mockBuilder = $ this ->getMockBuilder (\Magento \Catalog \Model \Product::class)
173
- ->setMethods (['getFinalPrice ' , '__wakeup ' ])
173
+ ->setMethods (['getPriceInfo ' , '__wakeup ' ])
174
174
->disableOriginalConstructor ();
175
175
$ mock = $ mockBuilder ->getMock ();
176
176
177
177
$ mock ->expects ($ this ->any ())
178
178
->method ('getFinalPrice ' )
179
179
->will ($ this ->returnValue (10 ));
180
+ $ priceInfoMock = $ this ->getMockForAbstractClass (
181
+ \Magento \Framework \Pricing \PriceInfoInterface::class,
182
+ [],
183
+ '' ,
184
+ false ,
185
+ false ,
186
+ true ,
187
+ ['getPrice ' ]
188
+ );
189
+
190
+ $ priceMock = $ this ->getMockForAbstractClass (\Magento \Framework \Pricing \Price \PriceInterface::class);
191
+
192
+ $ priceInfoMock ->expects ($ this ->any ())->method ('getPrice ' )->willReturn ($ priceMock );
193
+
194
+ $ mock ->expects ($ this ->any ())->method ('getPriceInfo ' )->willReturn ($ priceInfoMock );
195
+
196
+ $ priceMock ->expects ($ this ->any ())->method ('getValue ' )->willReturn (10 );
180
197
181
198
return $ mock ;
182
199
}
You can’t perform that action at this time.
0 commit comments