24 private $roundingErrorsNotification;
29 private $storeManagerMock;
34 private $urlBuilderMock;
39 private $taxConfigMock;
45 $websiteMock = $this->createMock(WebsiteInterface::class);
46 $websiteMock->expects($this->any())->method(
'getName')->willReturn(
'testWebsiteName');
47 $storeMock = $this->getMockForAbstractClass(
48 StoreInterface::class,
54 [
'getWebsite',
'getName']
56 $storeMock->expects($this->any())->method(
'getName')->willReturn(
'testStoreName');
57 $storeMock->expects($this->any())->method(
'getWebsite')->willReturn($websiteMock);
58 $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
59 $this->storeManagerMock->expects($this->any())->method(
'getStores')->willReturn([$storeMock]);
61 $this->urlBuilderMock = $this->createMock(UrlInterface::class);
62 $this->taxConfigMock = $this->createMock(TaxConfig::class);
63 $this->roundingErrorsNotification = (
new ObjectManager($this))->getObject(
64 RoundingErrorsNotification::class,
66 'storeManager' => $this->storeManagerMock,
67 'urlBuilder' => $this->urlBuilderMock,
68 'taxConfig' => $this->taxConfigMock,
75 $this->taxConfigMock->expects($this->any())->method(
'isWrongDisplaySettingsIgnored')->willReturn(
false);
77 $this->taxConfigMock->expects($this->any())
78 ->method(
'getAlgorithm')->willReturn(\
Magento\Tax\Model\Calculation::CALC_UNIT_BASE);
80 $this->taxConfigMock->expects($this->any())
82 $this->taxConfigMock->expects($this->any())
85 $this->taxConfigMock->expects($this->any())->method(
'displayCartPricesBoth')->willReturn(
false);
86 $this->taxConfigMock->expects($this->any())->method(
'displayCartSubtotalBoth')->willReturn(
false);
87 $this->taxConfigMock->expects($this->any())->method(
'displayCartShippingBoth')->willReturn(
false);
88 $this->taxConfigMock->expects($this->any())->method(
'displaySalesPricesBoth')->willReturn(
false);
89 $this->taxConfigMock->expects($this->any())->method(
'displaySalesSubtotalBoth')->willReturn(
false);
91 $this->taxConfigMock->expects($this->any())->method(
'displaySalesShippingBoth')->willReturn(
true);
93 $this->assertFalse($this->roundingErrorsNotification->isDisplayed());
98 $this->taxConfigMock->expects($this->any())->method(
'isWrongDisplaySettingsIgnored')->willReturn(
false);
100 $this->taxConfigMock->expects($this->any())
101 ->method(
'getAlgorithm')->willReturn(\
Magento\Tax\Model\Calculation::CALC_ROW_BASE);
103 $this->taxConfigMock->expects($this->any())
105 $this->taxConfigMock->expects($this->any())
108 $this->taxConfigMock->expects($this->any())->method(
'displayCartPricesBoth')->willReturn(
false);
109 $this->taxConfigMock->expects($this->any())->method(
'displayCartSubtotalBoth')->willReturn(
false);
110 $this->taxConfigMock->expects($this->any())->method(
'displayCartShippingBoth')->willReturn(
false);
111 $this->taxConfigMock->expects($this->any())->method(
'displaySalesPricesBoth')->willReturn(
false);
112 $this->taxConfigMock->expects($this->any())->method(
'displaySalesSubtotalBoth')->willReturn(
false);
113 $this->taxConfigMock->expects($this->any())->method(
'displaySalesShippingBoth')->willReturn(
false);
115 $this->assertFalse($this->roundingErrorsNotification->isDisplayed());
120 $this->taxConfigMock->expects($this->any())->method(
'isWrongDisplaySettingsIgnored')->willReturn(
true);
121 $this->assertFalse($this->roundingErrorsNotification->isDisplayed());
126 $this->taxConfigMock->expects($this->any())->method(
'isWrongDisplaySettingsIgnored')->willReturn(
false);
128 $this->taxConfigMock->expects($this->any())->method(
'displaySalesShippingBoth')->willReturn(
true);
130 $this->urlBuilderMock->expects($this->any())
132 ->with(
'tax/tax/ignoreTaxNotification', [
'section' =>
'price_display'])
133 ->willReturn(
'http://example.com');
134 $this->roundingErrorsNotification->isDisplayed();
136 '<strong>Your current tax configuration may result in rounding errors. ' 137 .
'</strong><p>Store(s) affected: testWebsiteName (testStoreName)</p><p>Click on the link to ' 138 .
'<a href="http://example.com">ignore this notification</a></p>',
139 $this->roundingErrorsNotification->getText()
const DISPLAY_TYPE_EXCLUDING_TAX
testIsDisplayedNotDisplayed()
testIsDisplayedIgnoreWrongConfiguration()
testIsDisplayedNotDisplayedUnitBased()