File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Test/Unit/Model/Product/Option Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 88
99namespace Magento \Catalog \Model \Product \Option ;
1010
11+ use Magento \Catalog \Pricing \Price \BasePrice ;
1112use Magento \Framework \Model \AbstractModel ;
1213use Magento \Catalog \Model \Product ;
1314use Magento \Catalog \Model \Product \Option ;
@@ -225,7 +226,7 @@ public function saveValues()
225226 public function getPrice ($ flag = false )
226227 {
227228 if ($ flag && $ this ->getPriceType () == self ::TYPE_PERCENT ) {
228- $ basePrice = $ this ->getOption ()->getProduct ()->getFinalPrice ();
229+ $ basePrice = $ this ->getOption ()->getProduct ()->getPriceInfo ()-> getPrice (BasePrice:: PRICE_CODE )-> getValue ();
229230 $ price = $ basePrice * ($ this ->_getData (self ::KEY_PRICE ) / 100 );
230231 return $ price ;
231232 }
Original file line number Diff line number Diff line change @@ -170,13 +170,30 @@ private function getMockedOption()
170170 private function getMockedProduct ()
171171 {
172172 $ mockBuilder = $ this ->getMockBuilder (\Magento \Catalog \Model \Product::class)
173- ->setMethods (['getFinalPrice ' , '__wakeup ' ])
173+ ->setMethods (['getPriceInfo ' , '__wakeup ' ])
174174 ->disableOriginalConstructor ();
175175 $ mock = $ mockBuilder ->getMock ();
176176
177177 $ mock ->expects ($ this ->any ())
178178 ->method ('getFinalPrice ' )
179179 ->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 );
180197
181198 return $ mock ;
182199 }
You can’t perform that action at this time.
0 commit comments