Skip to content

Commit bfecc27

Browse files
Merge remote-tracking branch 'remotes/github/MAGETWO-96847' into EPAM-PR-34
2 parents 18e3be4 + 2287ec1 commit bfecc27

File tree

7 files changed

+115
-15
lines changed

7 files changed

+115
-15
lines changed

app/code/Magento/Backend/Test/Mftf/Section/LocaleOptionsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<section name="LocaleOptionsSection">
1212
<element name="sectionHeader" type="text" selector="#general_locale-head"/>
1313
<element name="timezone" type="select" selector="#general_locale_timezone"/>
14+
<element name="useDefault" type="checkbox" selector="#general_locale_timezone_inherit"/>
1415
</section>
1516
</sections>

app/code/Magento/Bundle/Test/Unit/Pricing/Price/SpecialPriceTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Bundle\Test\Unit\Pricing\Price;
77

88
use \Magento\Bundle\Pricing\Price\SpecialPrice;
9+
use Magento\Store\Api\Data\WebsiteInterface;
910

1011
class SpecialPriceTest extends \PHPUnit\Framework\TestCase
1112
{
@@ -77,12 +78,6 @@ public function testGetValue($regularPrice, $specialPrice, $isScopeDateInInterva
7778
->method('getSpecialPrice')
7879
->will($this->returnValue($specialPrice));
7980

80-
$store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
81-
->disableOriginalConstructor()
82-
->getMock();
83-
$this->saleable->expects($this->once())
84-
->method('getStore')
85-
->will($this->returnValue($store));
8681
$this->saleable->expects($this->once())
8782
->method('getSpecialFromDate')
8883
->will($this->returnValue($specialFromDate));
@@ -92,7 +87,7 @@ public function testGetValue($regularPrice, $specialPrice, $isScopeDateInInterva
9287

9388
$this->localeDate->expects($this->once())
9489
->method('isScopeDateInInterval')
95-
->with($store, $specialFromDate, $specialToDate)
90+
->with(WebsiteInterface::ADMIN_CODE, $specialFromDate, $specialToDate)
9691
->will($this->returnValue($isScopeDateInInterval));
9792

9893
$this->priceCurrencyMock->expects($this->never())

app/code/Magento/Catalog/Model/Product/Type/Price.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
use Magento\Store\Model\Store;
1212
use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory;
1313
use Magento\Framework\App\ObjectManager;
14+
use Magento\Store\Api\Data\WebsiteInterface;
1415

1516
/**
1617
* Product type price model
1718
*
1819
* @api
1920
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2022
* @since 100.0.2
2123
*/
2224
class Price
@@ -184,6 +186,8 @@ public function getFinalPrice($qty, $product)
184186
}
185187

186188
/**
189+
* Retrieve final price for child product
190+
*
187191
* @param Product $product
188192
* @param float $productQty
189193
* @param Product $childProduct
@@ -428,6 +432,8 @@ public function setTierPrices($product, array $tierPrices = null)
428432
}
429433

430434
/**
435+
* Retrieve customer group id from product
436+
*
431437
* @param Product $product
432438
* @return int
433439
*/
@@ -453,7 +459,7 @@ protected function _applySpecialPrice($product, $finalPrice)
453459
$product->getSpecialPrice(),
454460
$product->getSpecialFromDate(),
455461
$product->getSpecialToDate(),
456-
$product->getStore()
462+
WebsiteInterface::ADMIN_CODE
457463
);
458464
}
459465

@@ -601,7 +607,7 @@ public function calculatePrice(
601607
$specialPrice,
602608
$specialPriceFrom,
603609
$specialPriceTo,
604-
$sId
610+
WebsiteInterface::ADMIN_CODE
605611
);
606612

607613
if ($rulePrice === false) {

app/code/Magento/Catalog/Pricing/Price/SpecialPrice.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Pricing\Price\AbstractPrice;
1212
use Magento\Framework\Pricing\Price\BasePriceProviderInterface;
1313
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
14+
use Magento\Store\Api\Data\WebsiteInterface;
1415

1516
/**
1617
* Special price model
@@ -46,6 +47,8 @@ public function __construct(
4647
}
4748

4849
/**
50+
* Retrieve special price.
51+
*
4952
* @return bool|float
5053
*/
5154
public function getValue()
@@ -96,19 +99,19 @@ public function getSpecialToDate()
9699
}
97100

98101
/**
99-
* @return bool
102+
* @inheritdoc
100103
*/
101104
public function isScopeDateInInterval()
102105
{
103106
return $this->localeDate->isScopeDateInInterval(
104-
$this->product->getStore(),
107+
WebsiteInterface::ADMIN_CODE,
105108
$this->getSpecialFromDate(),
106109
$this->getSpecialToDate()
107110
);
108111
}
109112

110113
/**
111-
* @return bool
114+
* @inheritdoc
112115
*/
113116
public function isPercentageDiscount()
114117
{

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductInfoMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<element name="productOptionAreaInput" type="textarea" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{var1}}')]/../div[@class='control']//textarea" parameterized="true"/>
2929
<element name="productOptionFile" type="file" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'OptionFile')]/../div[@class='control']//input[@type='file']" parameterized="true"/>
3030
<element name="productOptionSelect" type="select" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{var1}}')]/../div[@class='control']//select" parameterized="true"/>
31+
<element name="specialPriceValue" type="text" selector="//span[@class='special-price']//span[@class='price']"/>
3132

3233

3334
<!-- The parameter is the nth custom option that you want to get -->
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontSpecialPriceForDifferentTimezonesForWebsitesTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<title value="Check that special price displayed when 'default config' scope timezone does not match 'website' scope timezone"/>
15+
<description value="Check that special price displayed when 'default config' scope timezone does not match 'website' scope timezone"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-97508"/>
18+
<useCaseId value="MAGETWO-96847"/>
19+
<group value="Catalog"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
23+
24+
<!--Create product-->
25+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
26+
27+
<!--Create customer-->
28+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
29+
</before>
30+
<after>
31+
<!--Delete create data-->
32+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
33+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
34+
35+
<actionGroup ref="logout" stepKey="logout"/>
36+
</after>
37+
38+
<!--Set timezone for default config-->
39+
<amOnPage url="{{GeneralConfigurationPage.url}}" stepKey="goToGeneralConfig"/>
40+
<waitForPageLoad stepKey="waitForConfigPage"/>
41+
<conditionalClick selector="{{LocaleOptionsSection.sectionHeader}}" dependentSelector="{{LocaleOptionsSection.timezone}}" visible="false" stepKey="openLocaleSection"/>
42+
<grabValueFrom selector="{{LocaleOptionsSection.timezone}}" stepKey="originalTimezone"/>
43+
<selectOption selector="{{LocaleOptionsSection.timezone}}" userInput="Central European Standard Time (Europe/Paris)" stepKey="setTimezone"/>
44+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfig"/>
45+
46+
<!--Set timezone for Main Website-->
47+
<amOnPage url="{{GeneralConfigurationPage.url}}" stepKey="goToGeneralConfig1"/>
48+
<waitForPageLoad stepKey="waitForConfigPage1"/>
49+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="AdminSwitchStoreViewActionGroup">
50+
<argument name="website" value="_defaultWebsite"/>
51+
</actionGroup>
52+
<conditionalClick selector="{{LocaleOptionsSection.sectionHeader}}" dependentSelector="{{LocaleOptionsSection.timezone}}" visible="false" stepKey="openLocaleSection1"/>
53+
<uncheckOption selector="{{LocaleOptionsSection.useDefault}}" stepKey="uncheckUseDefault"/>
54+
<grabValueFrom selector="{{LocaleOptionsSection.timezone}}" stepKey="originalTimezone1"/>
55+
<selectOption selector="{{LocaleOptionsSection.timezone}}" userInput="Greenwich Mean Time (Africa/Abidjan)" stepKey="setTimezone1"/>
56+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfig1"/>
57+
58+
<!--Set special price to created product-->
59+
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="openAdminEditPage"/>
60+
<actionGroup ref="AddSpecialPriceToProductActionGroup" stepKey="setSpecialPriceToCreatedProduct">
61+
<argument name="price" value="15"/>
62+
</actionGroup>
63+
<actionGroup ref="saveProductForm" stepKey="saveProductForm"/>
64+
65+
<!--Login to storefront from customer and check price-->
66+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="logInFromCustomer">
67+
<argument name="Customer" value="$$createCustomer$$"/>
68+
</actionGroup>
69+
70+
<!--Go to the product page and check special price-->
71+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.name$$)}}" stepKey="amOnSimpleProductPage"/>
72+
<waitForPageLoad stepKey="waitForPageLoad"/>
73+
<grabTextFrom selector="{{StorefrontProductInfoMainSection.specialPriceValue}}" stepKey="grabSpecialPrice"/>
74+
<assertEquals expected='$15.00' expectedType="string" actual="$grabSpecialPrice" stepKey="assertSpecialPrice"/>
75+
76+
<!--Reset timezone-->
77+
<amOnPage url="{{GeneralConfigurationPage.url}}" stepKey="goToGeneralConfigReset"/>
78+
<waitForPageLoad stepKey="waitForConfigPageReset"/>
79+
<conditionalClick selector="{{LocaleOptionsSection.sectionHeader}}" dependentSelector="{{LocaleOptionsSection.timezone}}" visible="false" stepKey="openLocaleSectionReset"/>
80+
<selectOption selector="{{LocaleOptionsSection.timezone}}" userInput="$originalTimezone" stepKey="resetTimezone"/>
81+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfigReset"/>
82+
83+
<!--Reset timezone-->
84+
<amOnPage url="{{GeneralConfigurationPage.url}}" stepKey="goToGeneralConfigReset1"/>
85+
<waitForPageLoad stepKey="waitForConfigPageReset1"/>
86+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="AdminSwitchStoreViewActionGroup1">
87+
<argument name="website" value="_defaultWebsite"/>
88+
</actionGroup>
89+
<conditionalClick selector="{{LocaleOptionsSection.sectionHeader}}" dependentSelector="{{LocaleOptionsSection.timezone}}" visible="false" stepKey="openLocaleSectionReset1"/>
90+
<uncheckOption selector="{{LocaleOptionsSection.useDefault}}" stepKey="uncheckUseDefault1"/>
91+
<selectOption selector="{{LocaleOptionsSection.timezone}}" userInput="$originalTimezone" stepKey="resetTimezone1"/>
92+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfigReset1"/>
93+
</test>
94+
</tests>

app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/Grouped/PriceTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testGetFinalPrice(
6464
$expectedFinalPrice
6565
) {
6666
$rawFinalPrice = 10;
67-
$rawPriceCheckStep = 6;
67+
$rawPriceCheckStep = 5;
6868

6969
$this->productMock->expects(
7070
$this->any()
@@ -155,7 +155,7 @@ public function getFinalPriceDataProvider()
155155
'custom_option_null' => [
156156
'associatedProducts' => [],
157157
'options' => [[], []],
158-
'expectedPriceCall' => 6, /* product call number to check final price formed correctly */
158+
'expectedPriceCall' => 5, /* product call number to check final price formed correctly */
159159
'expectedFinalPrice' => 10, /* 10(product price) + 2(options count) * 5(qty) * 5(option price) */
160160
],
161161
'custom_option_exist' => [
@@ -165,7 +165,7 @@ public function getFinalPriceDataProvider()
165165
['associated_product_2', $optionMock],
166166
['associated_product_3', $optionMock],
167167
],
168-
'expectedPriceCall' => 16, /* product call number to check final price formed correctly */
168+
'expectedPriceCall' => 15, /* product call number to check final price formed correctly */
169169
'expectedFinalPrice' => 35, /* 10(product price) + 2(options count) * 5(qty) * 5(option price) */
170170
]
171171
];

0 commit comments

Comments
 (0)