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
185185 {
186186 return $ this ->amountRender ->getPriceType () === 'finalPrice '
187187 ? 'basePrice '
188- : 'base ' . ucfirst ($ this ->amountRender ->getPriceType ());
188+ : 'base ' . ucfirst ($ this ->amountRender ->getPriceType () ?? '' );
189189 }
190190}
Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ class AdjustmentTest extends TestCase
5454 */
5555 protected $ model ;
5656
57+ /**
58+ * @var AmountRenderInterface
59+ */
60+ protected $ amountRender ;
61+
5762 /**
5863 * Init mocks and model
5964 */
@@ -350,4 +355,26 @@ public function testGetHtmlBoth()
350355
351356 $ this ->model ->render ($ amountRender , $ arguments );
352357 }
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+ }
353380}
You can’t perform that action at this time.
0 commit comments