File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
Test/Unit/Model/Product/Type Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -379,7 +379,7 @@ public function getTierPrices($product)
379
379
if (array_key_exists ('website_price ' , $ price )) {
380
380
$ value = $ price ['website_price ' ];
381
381
} else {
382
- $ value = $ price ['price ' ];
382
+ $ value = $ price ['price ' ] ?? 0 ;
383
383
}
384
384
$ tierPrice ->setValue ($ value );
385
385
$ tierPrice ->setQty ($ price ['price_qty ' ]);
Original file line number Diff line number Diff line change @@ -263,4 +263,40 @@ function () {
263
263
);
264
264
}
265
265
}
266
+
267
+ /**
268
+ * Get tier price with percent value type
269
+ *
270
+ * @return void
271
+ */
272
+ public function testGetPricesWithPercentType (): void
273
+ {
274
+ $ tierPrices = [
275
+ 0 => [
276
+ 'record_id ' => 0 ,
277
+ 'cust_group ' => 3200 ,
278
+ 'price_qty ' => 3 ,
279
+ 'website_id ' => 0 ,
280
+ 'value_type ' => 'percent ' ,
281
+ 'percentage_value ' => 10 ,
282
+ ],
283
+ ];
284
+ $ this ->product ->setData ('tier_price ' , $ tierPrices );
285
+ $ this ->tpFactory ->expects ($ this ->any ())
286
+ ->method ('create ' )
287
+ ->willReturnCallback (
288
+ function () {
289
+ return $ this ->objectManagerHelper ->getObject (TierPrice::class);
290
+ }
291
+ );
292
+ $ tierPriceExtensionMock = $ this ->getMockBuilder (ProductTierPriceExtensionInterface::class)
293
+ ->onlyMethods (['getPercentageValue ' , 'setPercentageValue ' ])
294
+ ->getMockForAbstractClass ();
295
+ $ tierPriceExtensionMock ->method ('getPercentageValue ' )
296
+ ->willReturn (50 );
297
+ $ this ->tierPriceExtensionFactoryMock ->method ('create ' )
298
+ ->willReturn ($ tierPriceExtensionMock );
299
+
300
+ $ this ->assertInstanceOf (TierPrice::class, $ this ->model ->getTierPrices ($ this ->product )[0 ]);
301
+ }
266
302
}
You can’t perform that action at this time.
0 commit comments