Skip to content

Commit 10b6b04

Browse files
committed
Merge branch 'MC-40865' into 2.4-develop-sidecar-pr17
2 parents 33f29e0 + 9ba746e commit 10b6b04

File tree

8 files changed

+261
-16
lines changed

8 files changed

+261
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminProductFormAdvancedPricingAddTierPriceActionGroup" extends="AdminProductFormAdvancedPricingAddTierPriceActionGroup">
12+
<annotations>
13+
<description>Check tier price on Advanced Pricing dialog on the Admin Product creation/edit page.</description>
14+
</annotations>
15+
<remove keyForRemoval="selectWebsite"/>
16+
<remove keyForRemoval="selectCustomerGroup"/>
17+
<remove keyForRemoval="fillQuantity"/>
18+
<remove keyForRemoval="selectPriceType"/>
19+
<remove keyForRemoval="fillPriceAmount"/>
20+
<remove keyForRemoval="waitCustomerGroupFilterAppears"/>
21+
<remove keyForRemoval="selectCustomerGroupValue"/>
22+
<executeJS function="return window.getComputedStyle(document.querySelector(&quot;{$priceAmountSelector}&quot;)).getPropertyValue('min-width')" after="waitPriceAmountFieldAppers" stepKey="priceMinWidth"/>
23+
<assertEquals after="priceMinWidth" stepKey="assertWebsiteAmounts">
24+
<actualResult type="string">$priceMinWidth</actualResult>
25+
<expectedResult type="string">60px</expectedResult>
26+
</assertEquals>
27+
<click selector="{{AdminProductFormAdvancedPricingSection.customerGroupPriceDeleteButton}}" after="assertWebsiteAmounts" stepKey="clickCustomerGroupPriceDeleteButton"/>
28+
</actionGroup>
29+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/AdminApplyTierPriceToProductWithPercentageDiscountTest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<actionGroup ref="ResetProductGridToDefaultViewActionGroup" stepKey="resetGridToDefaultKeywordSearch"/>
3333
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
3434
</after>
35-
35+
3636
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="loginAsAdmin"/>
3737
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
3838
<argument name="product" value="$$createSimpleProduct$$"/>
@@ -41,6 +41,10 @@
4141
<argument name="product" value="$$createSimpleProduct$$"/>
4242
</actionGroup>
4343

44+
<actionGroup ref="AdminProductFormOpenAdvancedPricingDialogActionGroup" stepKey="clickOnAdvancedPricingButtonForAssert"/>
45+
<actionGroup ref="AssertAdminProductFormAdvancedPricingAddTierPriceActionGroup" stepKey="assertProductTierPriceInput"/>
46+
<actionGroup ref="AdminProductFormDoneAdvancedPricingDialogActionGroup" stepKey="doneButtonAfterAssert"/>
47+
4448
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="scrollToTopOfPage"/>
4549
<actionGroup ref="AdminProductFormOpenAdvancedPricingDialogActionGroup" stepKey="clickOnAdvancedPricingButton"/>
4650
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCustomerGroupPriceAddButton"/>

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerFiltersSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
<element name="viewDropdown" type="button" selector=".admin__data-grid-action-bookmarks button.admin__action-dropdown"/>
2020
<element name="viewBookmark" type="button" selector="//div[contains(@class, 'admin__data-grid-action-bookmarks')]/ul/li/div/a[text() = '{{label}}']" parameterized="true" timeout="30"/>
2121
<element name="countryOptions" type="button" selector=".admin__data-grid-filters select[name=billing_country_id] option"/>
22+
<element name="websiteOptions" type="button" selector=".admin__data-grid-filters select[name=website_id] option"/>
2223
</section>
2324
</sections>

app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
</column>
190190
<column name="website_id" class="Magento\Customer\Ui\Component\Listing\Column\Websites" component="Magento_Ui/js/grid/columns/select" sortOrder="110">
191191
<settings>
192+
<options class="Magento\Store\Model\ResourceModel\Website\Collection"/>
192193
<filter>select</filter>
193194
<editor>
194195
<editorType>select</editorType>

app/code/Magento/GraphQl/Controller/HttpRequestValidator/HttpVerbValidator.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,25 @@ public function validate(HttpRequestInterface $request) : void
3131
/** @var Http $request */
3232
if (false === $request->isPost()) {
3333
$query = $request->getParam('query', '');
34-
$operationType = null;
35-
$queryAst = \GraphQL\Language\Parser::parse(new \GraphQL\Language\Source($query ?: '', 'GraphQL'));
36-
\GraphQL\Language\Visitor::visit(
37-
$queryAst,
38-
[
39-
'leave' => [
40-
NodeKind::OPERATION_DEFINITION => function (Node $node) use (&$operationType) {
41-
$operationType = $node->operation;
42-
}
34+
if (!empty($query)) {
35+
$operationType = null;
36+
$queryAst = \GraphQL\Language\Parser::parse(new \GraphQL\Language\Source($query ?: '', 'GraphQL'));
37+
\GraphQL\Language\Visitor::visit(
38+
$queryAst,
39+
[
40+
'leave' => [
41+
NodeKind::OPERATION_DEFINITION => function (Node $node) use (&$operationType) {
42+
$operationType = $node->operation;
43+
}
44+
]
4345
]
44-
]
45-
);
46-
47-
if (strtolower($operationType) === 'mutation') {
48-
throw new GraphQlInputException(
49-
new \Magento\Framework\Phrase('Mutation requests allowed only for POST requests')
5046
);
47+
48+
if (strtolower($operationType) === 'mutation') {
49+
throw new GraphQlInputException(
50+
new \Magento\Framework\Phrase('Mutation requests allowed only for POST requests')
51+
);
52+
}
5153
}
5254
}
5355
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GraphQl\Test\Unit\Controller\HttpRequestValidator;
9+
10+
use Magento\Framework\App\HttpRequestInterface;
11+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
12+
use Magento\GraphQl\Controller\HttpRequestValidator\HttpVerbValidator;
13+
use PHPUnit\Framework\MockObject\MockObject;
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* Test HttpVerbValidator
18+
*/
19+
class HttpVerbValidatorTest extends TestCase
20+
{
21+
/**
22+
* @var HttpVerbValidator|MockObject
23+
*/
24+
private $httpVerbValidator;
25+
26+
/**
27+
* @var HttpRequestInterface|MockObject
28+
*/
29+
private $requestMock;
30+
31+
/**
32+
* @inheritDoc
33+
*/
34+
protected function setup(): void
35+
{
36+
$objectManager = new ObjectManager($this);
37+
$this->requestMock = $this->getMockBuilder(HttpRequestInterface::class)
38+
->disableOriginalConstructor()
39+
->onlyMethods(
40+
[
41+
'isPost',
42+
]
43+
)->addMethods(
44+
[
45+
'getParam',
46+
]
47+
)
48+
->getMockForAbstractClass();
49+
50+
$this->httpVerbValidator = $objectManager->getObject(
51+
HttpVerbValidator::class
52+
);
53+
}
54+
55+
/**
56+
* Test for validate method
57+
*
58+
* @param string $query
59+
* @param bool $needException
60+
* @dataProvider validateDataProvider
61+
*/
62+
public function testValidate(string $query, bool $needException): void
63+
{
64+
$this->requestMock
65+
->expects($this->once())
66+
->method('isPost')
67+
->willReturn(false);
68+
69+
$this->requestMock
70+
->method('getParam')
71+
->with('query', '')
72+
->willReturn($query);
73+
74+
if ($needException) {
75+
$this->expectExceptionMessage('Syntax Error: Unexpected <EOF>');
76+
}
77+
78+
$this->httpVerbValidator->validate($this->requestMock);
79+
}
80+
81+
/**
82+
* @return array
83+
*/
84+
public function validateDataProvider(): array
85+
{
86+
return [
87+
[
88+
'query' => '',
89+
'needException' => false,
90+
],
91+
[
92+
'query' => ' ',
93+
'needException' => true
94+
],
95+
];
96+
}
97+
}

app/design/adminhtml/Magento/backend/Magento_Catalog/web/css/source/_module.less

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@
9999
.admin__field + .admin__field {
100100
margin-left: @indent__s;
101101
margin-top: 0;
102+
.admin__field-control {
103+
.admin__control-addon {
104+
.admin__control-text {
105+
min-width: 6rem;
106+
}
107+
}
108+
}
102109
}
103110
}
104111
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Eav\Model\Entity\Attribute\Frontend;
9+
10+
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
11+
use Magento\Catalog\Api\ProductRepositoryInterface;
12+
use Magento\Framework\ObjectManagerInterface;
13+
use Magento\Framework\Stdlib\DateTime\DateTime;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
use Magento\TestFramework\Store\ExecuteInStoreContext;
16+
use PHPUnit\Framework\TestCase;
17+
18+
/**
19+
* Checks Datetime attribute's frontend model
20+
*
21+
* @magentoAppArea frontend
22+
*
23+
* @see \Magento\Eav\Model\Entity\Attribute\Frontend\Datetime
24+
*/
25+
class DatetimeTest extends TestCase
26+
{
27+
/**
28+
* @var int
29+
*/
30+
private const ONE_HOUR_IN_MILLISECONDS = 3600;
31+
32+
/**
33+
* @var ObjectManagerInterface
34+
*/
35+
private $objectManager;
36+
37+
/**
38+
* @var ProductAttributeRepositoryInterface
39+
*/
40+
private $attributeRepository;
41+
42+
/**
43+
* @var ProductRepositoryInterface
44+
*/
45+
private $productRepository;
46+
47+
/**
48+
* @var DateTime
49+
*/
50+
private $dateTime;
51+
52+
/**
53+
* @var ExecuteInStoreContext
54+
*/
55+
private $executeInStoreContext;
56+
57+
/**
58+
* @inheritdoc
59+
*/
60+
protected function setUp(): void
61+
{
62+
parent::setUp();
63+
64+
$this->objectManager = Bootstrap::getObjectManager();
65+
$this->attributeRepository = $this->objectManager->get(ProductAttributeRepositoryInterface::class);
66+
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
67+
$this->productRepository->cleanCache();
68+
$this->dateTime = $this->objectManager->create(DateTime::class);
69+
$this->executeInStoreContext = $this->objectManager->get(ExecuteInStoreContext::class);
70+
}
71+
72+
/**
73+
* @magentoDbIsolation disabled
74+
*
75+
* @magentoDataFixture Magento/Catalog/_files/product_two_websites.php
76+
* @magentoDataFixture Magento/Catalog/_files/product_datetime_attribute.php
77+
*
78+
* @magentoConfigFixture default_store general/locale/timezone Europe/Moscow
79+
* @magentoConfigFixture fixture_second_store_store general/locale/timezone Europe/Kiev
80+
*
81+
* @return void
82+
*/
83+
public function testFrontendValueOnDifferentWebsites(): void
84+
{
85+
$attribute = $this->attributeRepository->get('datetime_attribute');
86+
$product = $this->productRepository->get('simple-on-two-websites');
87+
$product->setDatetimeAttribute($this->dateTime->date('Y-m-d H:i:s'));
88+
$firstWebsiteValue = $this->executeInStoreContext->execute(
89+
'default',
90+
[$attribute->getFrontend(), 'getValue'],
91+
$product
92+
);
93+
$secondWebsiteValue = $this->executeInStoreContext->execute(
94+
'fixture_second_store',
95+
[$attribute->getFrontend(), 'getValue'],
96+
$product
97+
);
98+
$this->assertEquals(
99+
self::ONE_HOUR_IN_MILLISECONDS,
100+
$this->dateTime->gmtTimestamp($firstWebsiteValue) - $this->dateTime->gmtTimestamp($secondWebsiteValue),
101+
'The difference between values per different timezones is incorrect'
102+
);
103+
}
104+
}

0 commit comments

Comments
 (0)