27 private $applyDiscountOnPricesNotification;
32 private $storeManagerMock;
37 private $urlBuilderMock;
42 private $taxConfigMock;
48 $websiteMock = $this->createMock(WebsiteInterface::class);
49 $websiteMock->expects($this->any())->method(
'getName')->willReturn(
'testWebsiteName');
50 $storeMock = $this->getMockForAbstractClass(
51 StoreInterface::class,
57 [
'getWebsite',
'getName']
59 $storeMock->expects($this->any())->method(
'getName')->willReturn(
'testStoreName');
60 $storeMock->expects($this->any())->method(
'getWebsite')->willReturn($websiteMock);
61 $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
62 $this->storeManagerMock->expects($this->any())->method(
'getStores')->willReturn([$storeMock]);
64 $this->urlBuilderMock = $this->createMock(UrlInterface::class);
65 $this->taxConfigMock = $this->createMock(TaxConfig::class);
66 $this->applyDiscountOnPricesNotification = (
new ObjectManager($this))->getObject(
67 ApplyDiscountOnPricesNotification::class,
69 'storeManager' => $this->storeManagerMock,
70 'urlBuilder' => $this->urlBuilderMock,
71 'taxConfig' => $this->taxConfigMock,
80 $isWrongApplyDiscountSettingIgnored,
82 $applyTaxAfterDiscount,
86 $this->taxConfigMock->expects($this->any())->method(
'isWrongApplyDiscountSettingIgnored')
87 ->willReturn($isWrongApplyDiscountSettingIgnored);
88 $this->taxConfigMock->expects($this->any())->method(
'priceIncludesTax')->willReturn($priceIncludesTax);
89 $this->taxConfigMock->expects($this->any())->method(
'applyTaxAfterDiscount')
90 ->willReturn($applyTaxAfterDiscount);
91 $this->taxConfigMock->expects($this->any())->method(
'discountTax')->willReturn($discountTax);
93 $this->assertEquals($expectedResult, $this->applyDiscountOnPricesNotification->isDisplayed());
142 $this->taxConfigMock->expects($this->any())->method(
'isWrongApplyDiscountSettingIgnored')->willReturn(
false);
144 $this->taxConfigMock->expects($this->any())->method(
'priceIncludesTax')->willReturn(
false);
145 $this->taxConfigMock->expects($this->any())->method(
'applyTaxAfterDiscount')->willReturn(
true);
146 $this->taxConfigMock->expects($this->any())->method(
'discountTax')->willReturn(
true);
148 $this->urlBuilderMock->expects($this->any())
150 ->with(
'tax/tax/ignoreTaxNotification', [
'section' =>
'apply_discount'])
151 ->willReturn(
'http://example.com');
152 $this->applyDiscountOnPricesNotification->isDisplayed();
154 '<strong>To apply the discount on prices including tax and apply the tax after discount, ' 155 .
'set Catalog Prices to “Including Tax”. </strong><p>Store(s) affected: testWebsiteName ' 156 .
'(testStoreName)</p><p>Click on the link to ' 157 .
'<a href="http://example.com">ignore this notification</a></p>',
158 $this->applyDiscountOnPricesNotification->getText()
dataProviderIsDisplayed()
testIsDisplayed( $isWrongApplyDiscountSettingIgnored, $priceIncludesTax, $applyTaxAfterDiscount, $discountTax, $expectedResult)