File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,6 @@ public function getDataPriceType(): string
185
185
{
186
186
return $ this ->amountRender ->getPriceType () === 'finalPrice '
187
187
? 'basePrice '
188
- : 'base ' . ucfirst ($ this ->amountRender ->getPriceType ());
188
+ : 'base ' . ucfirst ($ this ->amountRender ->getPriceType () ?? '' );
189
189
}
190
190
}
Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ class AdjustmentTest extends TestCase
54
54
*/
55
55
protected $ model ;
56
56
57
+ /**
58
+ * @var AmountRenderInterface
59
+ */
60
+ protected $ amountRender ;
61
+
57
62
/**
58
63
* Init mocks and model
59
64
*/
@@ -350,4 +355,26 @@ public function testGetHtmlBoth()
350
355
351
356
$ this ->model ->render ($ amountRender , $ arguments );
352
357
}
358
+
359
+ /**
360
+ * test for method getDataPriceType
361
+ */
362
+ public function testGetDataPriceType (): void
363
+ {
364
+ $ amountRender = $ this ->getMockBuilder (Amount::class)
365
+ ->addMethods (['getPriceType ' ])
366
+ ->disableOriginalConstructor ()
367
+ ->getMock ();
368
+ $ amountRender ->expects ($ this ->atLeastOnce ())
369
+ ->method ('getPriceType ' )
370
+ ->willReturn ('finalPrice ' );
371
+ $ this ->model ->render ($ amountRender , []);
372
+ $ this ->assertEquals ('basePrice ' , $ this ->model ->getDataPriceType ());
373
+ $ amountRender ->expects ($ this ->atLeastOnce ())
374
+ ->method ('getPriceType ' )
375
+ ->willReturn ('anythingElse ' );
376
+ $ this ->model ->render ($ amountRender , []);
377
+ //no exception thrown
378
+ $ this ->assertIsString ($ this ->model ->getDataPriceType ());
379
+ }
353
380
}
You can’t perform that action at this time.
0 commit comments