Skip to content

Commit 6108654

Browse files
committed
Merge remote-tracking branch 'origin/ACP2E-3813' into PR_2025_07_08_muntianu
2 parents c5c32f2 + 3a4a6ac commit 6108654

File tree

7 files changed

+195
-152
lines changed

7 files changed

+195
-152
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public function execute()
143143
$this->validateProductAttributes($attributesData);
144144
$this->publish($attributesData, $websiteRemoveData, $websiteAddData, $storeId, $websiteId, $productIds);
145145
$this->messageManager->addSuccessMessage(__('Message is added to queue'));
146+
$this->attributeHelper->setProductIds([]);
146147
} catch (LocalizedException $e) {
147148
$this->messageManager->addErrorMessage($e->getMessage());
148149
} catch (\Exception $e) {

app/code/Magento/Customer/Test/Mftf/Test/AdminCustomerAddressAttributeWebsiteScopeTest.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
6-
*/
3+
/**
4+
* Copyright 2022 Adobe
5+
* All Rights Reserved.
6+
*/
77
-->
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -99,6 +99,9 @@
9999
</actionGroup>
100100
<!-- Logout from admin -->
101101
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
102+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
103+
<argument name="indices" value=""/>
104+
</actionGroup>
102105
</after>
103106
<!-- Open the customer edit page -->
104107
<actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="goToCustomerEditPage">

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php renamed to dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php

Lines changed: 18 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
6-
namespace Magento\Catalog\Controller\Adminhtml\Product\Action;
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute;
79

810
use Magento\Backend\Model\Session;
911
use Magento\Catalog\Block\Product\ListProduct;
1012
use Magento\Catalog\Helper\Product\Edit\Action\Attribute;
1113
use Magento\Catalog\Model\CategoryFactory;
1214
use Magento\Catalog\Model\Product\Visibility;
13-
use Magento\Framework\Message\MessageInterface;
1415
use Magento\Catalog\Model\ProductRepository;
1516
use Magento\Framework\App\Request\Http as HttpRequest;
17+
use Magento\Framework\Message\MessageInterface;
1618
use Magento\Framework\UrlInterface;
17-
use Magento\TestFramework\Helper\Bootstrap;
1819
use Magento\TestFramework\MessageQueue\EnvironmentPreconditionException;
1920
use Magento\TestFramework\MessageQueue\PreconditionFailedException;
2021
use Magento\TestFramework\MessageQueue\PublisherConsumerController;
2122
use Magento\TestFramework\TestCase\AbstractBackendController;
2223

2324
/**
25+
* @covers \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save::execute
2426
* @magentoAppArea adminhtml
2527
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2628
*/
27-
class AttributeTest extends AbstractBackendController
29+
class SaveTest extends AbstractBackendController
2830
{
2931
/** @var PublisherConsumerController */
3032
private $publisherConsumerController;
33+
3134
/**
3235
* @var string[]
3336
*/
@@ -39,22 +42,14 @@ protected function setUp(): void
3942

4043
$this->publisherConsumerController = $this->_objectManager->create(
4144
PublisherConsumerController::class,
42-
[
43-
'consumers' => $this->consumers,
44-
'logFilePath' => TESTS_TEMP_DIR . "/MessageQueueTestLog.txt",
45-
'maxMessages' => null,
46-
'appInitParams' => Bootstrap::getInstance()->getAppInitParams()
47-
]
45+
['consumers' => $this->consumers]
4846
);
49-
5047
try {
5148
$this->publisherConsumerController->startConsumers();
5249
} catch (EnvironmentPreconditionException $e) {
5350
$this->markTestSkipped($e->getMessage());
5451
} catch (PreconditionFailedException $e) {
55-
$this->fail(
56-
$e->getMessage()
57-
);
52+
$this->fail($e->getMessage());
5853
}
5954
}
6055

@@ -65,12 +60,10 @@ protected function tearDown(): void
6560
}
6661

6762
/**
68-
* @covers \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save::execute
69-
*
7063
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
7164
* @magentoDbIsolation disabled
7265
*/
73-
public function testSaveActionRedirectsSuccessfully()
66+
public function testSaveActionRedirectsSuccessfully(): void
7467
{
7568
/** @var $session Session */
7669
$session = $this->_objectManager->get(Session::class);
@@ -100,14 +93,12 @@ public function testSaveActionRedirectsSuccessfully()
10093
}
10194

10295
/**
103-
* @covers \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save::execute
104-
*
10596
* @dataProvider saveActionVisibilityAttrDataProvider
10697
* @param array $attributes
10798
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
10899
* @magentoDbIsolation disabled
109100
*/
110-
public function testSaveActionChangeVisibility($attributes)
101+
public function testSaveActionChangeVisibility(array $attributes): void
111102
{
112103
/** @var ProductRepository $repository */
113104
$repository = $this->_objectManager->create(ProductRepository::class);
@@ -129,88 +120,26 @@ public function testSaveActionChangeVisibility($attributes)
129120
/** @var ListProduct $listProduct */
130121
$listProduct = $this->_objectManager->get(ListProduct::class);
131122

132-
sleep(30); // timeout to processing queue
133123
$this->publisherConsumerController->waitForAsynchronousResult(
134-
function () use ($repository) {
135-
sleep(10); // Should be refactored in the scope of MC-22947
136-
return $repository->get(
137-
'simple',
138-
false,
139-
null,
140-
true
141-
)->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE;
142-
},
143-
[]
124+
fn () => (int) $repository->get('simple', forceReload: true)->getVisibility()
125+
!== Visibility::VISIBILITY_NOT_VISIBLE
144126
);
145127

146128
$category = $categoryFactory->create()->load(2);
147129
$layer = $listProduct->getLayer();
148130
$layer->setCurrentCategory($category);
149131
$productCollection = $layer->getProductCollection();
150132
$productItem = $productCollection->getFirstItem();
151-
$this->assertEquals($session->getProductIds(), [$productItem->getId()]);
152-
}
153-
154-
/**
155-
* @param array $attributes Request parameter.
156-
*
157-
* @covers \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Validate::execute
158-
*
159-
* @dataProvider validateActionDataProvider
160-
*
161-
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
162-
* @magentoDataFixture Magento/Catalog/_files/product_simple_duplicated.php
163-
* @magentoDbIsolation disabled
164-
*/
165-
public function testValidateActionWithMassUpdate($attributes)
166-
{
167-
/** @var $session Session */
168-
$session = $this->_objectManager->get(Session::class);
169-
$session->setProductIds([1, 2]);
170-
171-
$this->getRequest()->setParam('attributes', $attributes);
172-
173-
$this->dispatch('backend/catalog/product_action_attribute/validate/store/0');
174-
175-
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
176-
177-
$response = $this->getResponse()->getBody();
178-
$this->assertJson($response);
179-
$data = json_decode($response, true);
180-
$this->assertArrayHasKey('error', $data);
181-
$this->assertFalse($data['error']);
182-
$this->assertCount(1, $data);
183-
}
184-
185-
/**
186-
* Data Provider for validation
187-
*
188-
* @return array
189-
*/
190-
public static function validateActionDataProvider()
191-
{
192-
return [
193-
[
194-
'attributes' => [
195-
'name' => 'Name',
196-
'description' => 'Description',
197-
'short_description' => 'Short Description',
198-
'price' => '512',
199-
'weight' => '16',
200-
'meta_title' => 'Meta Title',
201-
'meta_keyword' => 'Meta Keywords',
202-
'meta_description' => 'Meta Description',
203-
],
204-
]
205-
];
133+
$this->assertEquals([$product->getId()], [$productItem->getId()]);
134+
$this->assertEmpty($session->getProductIds());
206135
}
207136

208137
/**
209138
* Data Provider for save with visibility attribute
210139
*
211140
* @return array
212141
*/
213-
public static function saveActionVisibilityAttrDataProvider()
142+
public static function saveActionVisibilityAttrDataProvider(): array
214143
{
215144
return [
216145
['attributes' => ['visibility' => Visibility::VISIBILITY_BOTH]],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute;
9+
10+
use Magento\Backend\Model\Session;
11+
use Magento\Catalog\Model\CategoryFactory;
12+
use Magento\TestFramework\TestCase\AbstractBackendController;
13+
14+
/**
15+
* @covers \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Validate::execute
16+
* @magentoAppArea adminhtml
17+
*/
18+
class ValidateTest extends AbstractBackendController
19+
{
20+
/**
21+
* @param array $attributes Request parameter.
22+
* @dataProvider validateActionDataProvider
23+
*
24+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
25+
* @magentoDataFixture Magento/Catalog/_files/product_simple_duplicated.php
26+
* @magentoDbIsolation disabled
27+
*/
28+
public function testValidateActionWithMassUpdate(array $attributes): void
29+
{
30+
$session = $this->_objectManager->get(Session::class);
31+
$session->setProductIds([1, 2]);
32+
33+
$this->getRequest()->setParam('attributes', $attributes);
34+
$this->dispatch('backend/catalog/product_action_attribute/validate/store/0');
35+
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
36+
37+
$response = $this->getResponse()->getBody();
38+
$this->assertJson($response);
39+
$data = json_decode($response, true);
40+
$this->assertArrayHasKey('error', $data);
41+
$this->assertFalse($data['error']);
42+
$this->assertCount(1, $data);
43+
}
44+
45+
/**
46+
* Data Provider for validation
47+
*
48+
* @return array
49+
*/
50+
public static function validateActionDataProvider(): array
51+
{
52+
return [
53+
[
54+
'attributes' => [
55+
'name' => 'Name',
56+
'description' => 'Description',
57+
'short_description' => 'Short Description',
58+
'price' => '512',
59+
'weight' => '16',
60+
'meta_title' => 'Meta Title',
61+
'meta_keyword' => 'Meta Keywords',
62+
'meta_description' => 'Meta Description',
63+
],
64+
],
65+
];
66+
}
67+
}

dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
use Magento\Customer\Api\CustomerRepositoryInterface;
1010
use Magento\Customer\Api\Data\CustomerInterface;
1111
use Magento\Customer\Model\Indexer\Processor;
12+
use Magento\Customer\Model\ResourceModel\Customer\Collection as CustomerCollection;
1213
use Magento\Framework\App\Filesystem\DirectoryList;
1314
use Magento\Framework\Exception\NoSuchEntityException;
1415
use Magento\Framework\Filesystem\Directory\Write as DirectoryWrite;
1516
use Magento\Framework\Filesystem\File\WriteFactory;
1617
use Magento\Framework\Indexer\StateInterface;
1718
use Magento\Framework\ObjectManagerInterface;
19+
use Magento\Framework\Registry;
1820
use Magento\ImportExport\Model\Import;
1921
use Magento\ImportExport\Model\Import\Source\CsvFactory;
2022
use Magento\TestFramework\Helper\Bootstrap;
@@ -95,6 +97,24 @@ protected function setUp(): void
9597
$this->csvFactory = $this->objectManager->get(CsvFactory::class);
9698
}
9799

100+
/**
101+
* @inheritdoc
102+
*/
103+
protected function tearDown(): void
104+
{
105+
$registry = $this->objectManager->get(Registry::class);
106+
$registry->unregister('isSecureArea');
107+
$registry->register('isSecureArea', true);
108+
try {
109+
$customerCollection = $this->objectManager->create(CustomerCollection::class);
110+
$customerCollection->delete();
111+
} finally {
112+
$registry->unregister('isSecureArea');
113+
$registry->register('isSecureArea', false);
114+
}
115+
parent::tearDown();
116+
}
117+
98118
/**
99119
* Test importData() method
100120
*
@@ -113,9 +133,9 @@ public function testImportData()
113133

114134
$existingCustomer = $this->getCustomer('[email protected]', 1);
115135

116-
/** @var $customersCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
136+
/** @var $customersCollection CustomerCollection */
117137
$customersCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
118-
\Magento\Customer\Model\ResourceModel\Customer\Collection::class
138+
CustomerCollection::class
119139
);
120140
$customersCollection->addAttributeToSelect('firstname', 'inner')->addAttributeToSelect('lastname', 'inner');
121141

@@ -276,9 +296,9 @@ public function testImportDataWithOneAdditionalColumn(): void
276296
$existingCustomer->setWebsiteId(1);
277297
$existingCustomer = $existingCustomer->loadByEmail('[email protected]');
278298

279-
/** @var $customersCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
299+
/** @var $customersCollection CustomerCollection */
280300
$customersCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
281-
\Magento\Customer\Model\ResourceModel\Customer\Collection::class
301+
CustomerCollection::class
282302
);
283303
$customersCollection->resetData();
284304
$customersCollection->clear();
@@ -346,9 +366,9 @@ public function testDeleteData()
346366
$this->directoryWrite
347367
);
348368

349-
/** @var $customerCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
369+
/** @var $customerCollection CustomerCollection */
350370
$customerCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
351-
\Magento\Customer\Model\ResourceModel\Customer\Collection::class
371+
CustomerCollection::class
352372
);
353373
$this->assertEquals(3, $customerCollection->count(), 'Count of existing customers are invalid');
354374

lib/internal/Magento/Framework/Session/SaveHandler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2013 Adobe
4+
* All Rights Reserved.
55
*/
6-
76
namespace Magento\Framework\Session;
87

98
use Magento\Framework\App\Area;
@@ -17,7 +16,6 @@
1716
use Psr\Log\LoggerInterface;
1817

1918
/**
20-
* Magento session save handler.
2119
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2220
*/
2321
class SaveHandler implements SaveHandlerInterface, ResetAfterRequestInterface
@@ -127,7 +125,9 @@ public function read($sessionId): string
127125
$sessionMaxSize = $this->sessionMaxSizeConfig->getSessionMaxSize();
128126
$sessionSize = $sessionData !== null ? strlen($sessionData) : 0;
129127

130-
if ($sessionMaxSize !== null && $sessionMaxSize < $sessionSize) {
128+
if ($sessionMaxSize !== null && $sessionMaxSize < $sessionSize
129+
&& $this->appState->getAreaCode() !== Area::AREA_ADMINHTML
130+
) {
131131
$sessionData = '';
132132
if ($this->appState->getAreaCode() === Area::AREA_FRONTEND) {
133133
$this->messageManager->addErrorMessage(

0 commit comments

Comments
 (0)