24 private $discountErrorsNotification;
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->discountErrorsNotification = (
new ObjectManager($this))->getObject(
64 DiscountErrorsNotification::class,
66 'storeManager' => $this->storeManagerMock,
67 'urlBuilder' => $this->urlBuilderMock,
68 'taxConfig' => $this->taxConfigMock,
75 $this->taxConfigMock->expects($this->any())->method(
'applyTaxAfterDiscount')->willReturn(
false);
76 $this->taxConfigMock->expects($this->any())->method(
'isWrongDiscountSettingsIgnored')->willReturn(
false);
77 $this->assertTrue($this->discountErrorsNotification->isDisplayed());
82 $this->taxConfigMock->expects($this->any())->method(
'applyTaxAfterDiscount')->willReturn(
false);
83 $this->taxConfigMock->expects($this->any())->method(
'isWrongDiscountSettingsIgnored')->willReturn(
true);
84 $this->assertFalse($this->discountErrorsNotification->isDisplayed());
89 $this->taxConfigMock->expects($this->any())->method(
'applyTaxAfterDiscount')->willReturn(
false);
90 $this->taxConfigMock->expects($this->any())->method(
'isWrongDiscountSettingsIgnored')->willReturn(
false);
91 $this->urlBuilderMock->expects($this->any())
93 ->with(
'tax/tax/ignoreTaxNotification', [
'section' =>
'discount'])
94 ->willReturn(
'http://example.com');
95 $this->discountErrorsNotification->isDisplayed();
97 '<strong>With customer tax applied “Before Discount”, the final discount calculation may not match ' 98 .
'customers’ expectations. </strong><p>Store(s) affected: testWebsiteName (testStoreName)' 99 .
'</p><p>Click on the link to <a href="http://example.com">ignore this notification</a></p>',
100 $this->discountErrorsNotification->getText()
testIsDisplayedIgnoreWrongConfiguration()