Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/2.4-develop' into ACP2E-2201
Browse files Browse the repository at this point in the history
  • Loading branch information
o-dubovyk committed Oct 13, 2023
2 parents 3674d12 + 2932016 commit 412997e
Show file tree
Hide file tree
Showing 1,969 changed files with 65,127 additions and 67,361 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@
<before>
<!--Enable Async Configuration-->
<magentoCLI stepKey="EnableAsyncConfig" command="setup:config:set --no-interaction --config-async 1"/>
<magentoCLI stepKey="ClearConfigCache" command="cache:flush"/>
<actionGroup ref="CliCacheFlushActionGroup" stepKey="ClearConfigCache">
<argument name="tags" value=""/>
</actionGroup>
<!--Login to Admin-->
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
</before>
<after>
<magentoCLI stepKey="DisableAsyncConfig" command="setup:config:set --no-interaction --config-async 0"/>
<magentoCLI stepKey="setBackDefaultConfigValue" command="config:set catalog/frontend/grid_per_page 12" />
<magentoCLI stepKey="ClearConfigCache" command="cache:clean"/>
<actionGroup ref="CliCacheCleanActionGroup" stepKey="ClearConfigCache">
<argument name="tags" value="config"/>
</actionGroup>
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
</after>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
class Plugin
{
private const MESSAGES_LIMIT = 5;
/**
* @var \Magento\AdminNotification\Model\System\MessageFactory
*/
Expand Down Expand Up @@ -95,27 +96,32 @@ public function afterToArray(
$this->bulkNotificationManagement->getAcknowledgedBulksByUser($userId)
);
$bulkMessages = [];
$messagesCount = 0;
$data = [];
foreach ($userBulks as $bulk) {
$bulkUuid = $bulk->getBulkId();
if (!in_array($bulkUuid, $acknowledgedBulks)) {
$details = $this->operationDetails->getDetails($bulkUuid);
$text = $this->getText($details);
$bulkStatus = $this->statusMapper->operationStatusToBulkSummaryStatus($bulk->getStatus());
if ($bulkStatus === \Magento\Framework\Bulk\BulkSummaryInterface::IN_PROGRESS) {
$text = __('%1 item(s) are currently being updated.', $details['operations_total']) . $text;
if ($messagesCount < self::MESSAGES_LIMIT) {
$details = $this->operationDetails->getDetails($bulkUuid);
$text = $this->getText($details);
$bulkStatus = $this->statusMapper->operationStatusToBulkSummaryStatus($bulk->getStatus());
if ($bulkStatus === \Magento\Framework\Bulk\BulkSummaryInterface::IN_PROGRESS) {
$text = __('%1 item(s) are currently being updated.', $details['operations_total']) . $text;
}
$data = [
'data' => [
'text' => __('Task "%1": ', $bulk->getDescription()) . $text,
'severity' => \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR,
// md5() here is not for cryptographic use.
// phpcs:ignore Magento2.Security.InsecureFunction
'identity' => md5('bulk' . $bulkUuid),
'uuid' => $bulkUuid,
'status' => $bulkStatus,
'created_at' => $bulk->getStartTime()
]
];
$messagesCount++;
}
$data = [
'data' => [
'text' => __('Task "%1": ', $bulk->getDescription()) . $text,
'severity' => \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR,
// md5() here is not for cryptographic use.
// phpcs:ignore Magento2.Security.InsecureFunction
'identity' => md5('bulk' . $bulkUuid),
'uuid' => $bulkUuid,
'status' => $bulkStatus,
'created_at' => $bulk->getStartTime()
]
];
$bulkMessages[] = $this->messageFactory->create($data)->toArray();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
class PluginTest extends TestCase
{
private const MESSAGES_LIMIT = 5;
/**
* @var Plugin
*/
Expand Down Expand Up @@ -163,6 +164,60 @@ public function testAfterTo($operationDetails)
$this->assertEquals(2, $result2['totalRecords']);
}

/**
* Tests that message building operations don't get called more than Plugin::MESSAGES_LIMIT times
*
* @return void
*/
public function testAfterToWithMessageLimit()
{
$result = ['items' =>[], 'totalRecords' => 1];
$messagesCount = self::MESSAGES_LIMIT + 1;
$userId = 1;
$bulkUuid = 2;
$bulkArray = [
'status' => BulkSummaryInterface::NOT_STARTED
];

$bulkMock = $this->getMockBuilder(BulkSummary::class)
->addMethods(['getStatus'])
->onlyMethods(['getBulkId', 'getDescription', 'getStartTime'])
->disableOriginalConstructor()
->getMock();
$userBulks = array_fill(0, $messagesCount, $bulkMock);
$bulkMock->expects($this->exactly($messagesCount))
->method('getBulkId')->willReturn($bulkUuid);
$this->operationsDetailsMock
->expects($this->exactly(self::MESSAGES_LIMIT))
->method('getDetails')
->with($bulkUuid)
->willReturn([
'operations_successful' => 1,
'operations_failed' => 0
]);
$bulkMock->expects($this->exactly(self::MESSAGES_LIMIT))
->method('getDescription')->willReturn('Bulk Description');
$this->messagefactoryMock->expects($this->exactly($messagesCount))
->method('create')->willReturn($this->messageMock);
$this->messageMock->expects($this->exactly($messagesCount))->method('toArray')->willReturn($bulkArray);
$this->authorizationMock
->expects($this->once())
->method('isAllowed')
->with($this->resourceName)
->willReturn(true);
$this->userContextMock->expects($this->once())->method('getUserId')->willReturn($userId);
$this->bulkNotificationMock
->expects($this->once())
->method('getAcknowledgedBulksByUser')
->with($userId)
->willReturn([]);
$this->statusMapper->expects($this->exactly(self::MESSAGES_LIMIT))
->method('operationStatusToBulkSummaryStatus');
$this->bulkStatusMock->expects($this->once())->method('getBulksByUser')->willReturn($userBulks);
$result2 = $this->plugin->afterToArray($this->collectionMock, $result);
$this->assertEquals($result['totalRecords'] + $messagesCount, $result2['totalRecords']);
}

/**
* @return array
*/
Expand Down
16 changes: 12 additions & 4 deletions app/code/Magento/AwsS3/Driver/AwsS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,16 +893,24 @@ public function fileClose($resource): bool
*/
public function fileOpen($path, $mode)
{
$_mode = str_replace(['b', '+'], '', strtolower($mode));
if (!in_array($_mode, ['r', 'w', 'a'], true)) {
throw new FileSystemException(new Phrase('Invalid file open mode "%1".', [$mode]));
}
$path = $this->normalizeRelativePath($path, true);

if (!isset($this->streams[$path])) {
$this->streams[$path] = tmpfile();
try {
if ($this->adapter->fileExists($path)) {
//phpcs:ignore Magento2.Functions.DiscouragedFunction
fwrite($this->streams[$path], $this->adapter->read($path));
//phpcs:ignore Magento2.Functions.DiscouragedFunction
rewind($this->streams[$path]);
if ($_mode !== 'w') {
//phpcs:ignore Magento2.Functions.DiscouragedFunction
fwrite($this->streams[$path], $this->adapter->read($path));
//phpcs:ignore Magento2.Functions.DiscouragedFunction
if ($_mode !== 'a') {
rewind($this->streams[$path]);
}
}
}
} catch (FlysystemFilesystemException $e) {
$this->logger->error($e->getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<comment userInput="BIC workaround" stepKey="disableRemoteStorage"/>
<magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/>
<!-- Delete customer -->
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer" />
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>

<!-- Delete category -->
Expand Down Expand Up @@ -81,7 +82,9 @@

<!-- Save product -->
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
<magentoCron stepKey="runIndexCronJobs" groups="index"/>
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="runIndexCronJobs">
<argument name="indices" value=""/>
</actionGroup>

<!-- Login to frontend -->
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="signIn">
Expand Down
99 changes: 99 additions & 0 deletions app/code/Magento/AwsS3/Test/Mftf/test-dependency-allowlist
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
AdminExportTaxRatesTest
ImportProduct_Bundle
ImportProductSimple1_Bundle
ImportProductSimple2_Bundle
ImportProductSimple3_Bundle
CliCacheFlushActionGroup
AdminFillImportFormActionGroup
ImportProduct_Downloadable_FileLinks
ImportProduct_Downloadable_UrlLinks
ImportProduct_Grouped
ImportProductSimple1_Grouped
ImportProductSimple2_Grouped
ImportProductSimple3_Grouped
ImportProduct_Configurable
ImportProductSimple1_Configurable
ImportProductSimple2_Configurable
ImportProductSimple3_Configurable
placeholderBaseImage
placeholderSmallImage
placeholderThumbnailImage
AdminImportTaxRatesTest
AdminMediaGalleryFolderData
AdminMediaGalleryFolder2Data
ImageUpload
AdminLoginActionGroup
AdminOpenStandaloneMediaGalleryActionGroup
ResetAdminDataGridToDefaultViewActionGroup
AdminMediaGalleryFolderSelectActionGroup
AdminMediaGalleryOpenNewFolderFormActionGroup
AdminMediaGalleryCreateNewFolderActionGroup
AdminEnhancedMediaGalleryUploadImageActionGroup
AdminExpandMediaGalleryFolderActionGroup
AdminMediaGalleryFolderDeleteActionGroup
AdminLogoutActionGroup
NavigateToCreatedCMSPageActionGroup
AdminOpenMediaGalleryFromPageNoEditorActionGroup
AdminMediaGalleryClickImageInGridActionGroup
AdminMediaGalleryClickAddSelectedActionGroup
AdminSaveAndContinueEditCmsPageActionGroup
NavigateToStorefrontForCreatedPageActionGroup
AdminMediaGalleryAssertFolderDoesNotExistActionGroup
AdminEnhancedMediaGalleryImageDeleteActionGroup
AdminMediaGalleryAssertImageNotExistsInTheGridActionGroup
StorefrontProductMediaSection
RedPngImageContent
BluePngImageContent
MagentoPlaceHolderImageContent
StorefrontOpenProductEntityPageActionGroup
AdminGoToCacheManagementPageActionGroup
AdminClickFlushCatalogImagesCacheActionGroup
placeholderBaseImageLongName
AdminAddImageForCategoryTest
AdminAddImageToWYSIWYGBlockTest
AdminAddImageToWYSIWYGCMSTest
AdminAddImageToWYSIWYGNewsletterTest
AdminAddRemoveDefaultVideoSimpleProductTest
AdminProductFormSection
AdminProductDownloadableSection
downloadableData
StorefrontProductInfoMainSection
DownloadableProduct
StorefrontDownloadableProductSection
StorefrontDownloadableLinkSection
CheckoutCartProductSection
StorefrontCustomerDownloadableProductsSection
downloadableLinkWithMaxDownloads
downloadableLink
downloadableSampleFile
StorefrontCustomerLogoutActionGroup
DeleteProductUsingProductGridActionGroup
AdminOpenProductIndexPageActionGroup
GoToSpecifiedCreateProductPageActionGroup
FillMainProductFormNoWeightActionGroup
AddDownloadableProductLinkWithMaxDownloadsActionGroup
AddDownloadableProductLinkActionGroup
AddDownloadableSampleFileActionGroup
SaveProductFormActionGroup
CliIndexerReindexActionGroup
LoginToStorefrontActionGroup
StorefrontCheckProductPriceInCategoryActionGroup
AssertProductNameAndSkuInStorefrontProductPageActionGroup
AssertStorefrontSeeElementActionGroup
StorefrontAddProductToCartActionGroup
StorefrontCartPageOpenActionGroup
StorefrontOpenCheckoutPageActionGroup
CheckoutSelectCheckMoneyOrderPaymentActionGroup
ClickPlaceOrderActionGroup
StorefrontClickOrderLinkFromCheckoutSuccessPageActionGroup
AdminOpenOrderByEntityIdActionGroup
StartCreateInvoiceFromOrderPageActionGroup
SubmitInvoiceActionGroup
StorefrontAssertDownloadableProductIsPresentInCustomerAccount
AdminMarketingCreateSitemapEntityTest
AdminMarketingSiteMapCreateNewTest
CheckingRMAPrintTest
ConfigurableProductChildImageShouldBeShownOnWishListTest
StorefrontCaptchaOnCustomerLoginTest
StorefrontPrintOrderGuestTest
UpdateImageFileCustomerAttributeTest
Loading

0 comments on commit 412997e

Please sign in to comment.