Skip to content

Commit e1f4633

Browse files
committed
Merge branch '2.4-develop' into Refactoring-StorefrontConfigurableProductCanAddToCartTest
2 parents 6cfe41b + 800acfa commit e1f4633

File tree

162 files changed

+6479
-550
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+6479
-550
lines changed

app/code/Magento/AwsS3/Test/Mftf/Helper/S3FileAssertions.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,49 @@ public function deleteFileIfExists($filePath): void
9292
}
9393
}
9494

95+
/**
96+
* Copy source into destination
97+
*
98+
* @param string $source
99+
* @param string $destination
100+
* @return void
101+
*
102+
* @throws \Magento\Framework\Exception\FileSystemException
103+
*/
104+
public function copy($source, $destination): void
105+
{
106+
$this->driver->copy($source, $destination);
107+
}
108+
109+
/**
110+
* Create directory in the S3 bucket
111+
*
112+
* @param string $path
113+
* @param int $permissions
114+
* @return void
115+
*
116+
* @throws \Magento\Framework\Exception\FileSystemException
117+
*/
118+
public function createDirectory($path, $permissions = 0777): void
119+
{
120+
$this->driver->createDirectory($path, $permissions);
121+
}
122+
123+
/**
124+
* Recursive delete directory in the S3 bucket
125+
*
126+
* @param string $path
127+
* @return void
128+
*
129+
* @throws \Magento\Framework\Exception\FileSystemException
130+
*/
131+
public function deleteDirectory($path): void
132+
{
133+
if ($this->driver->isExists($path)) {
134+
$this->driver->deleteDirectory($path);
135+
}
136+
}
137+
95138
/**
96139
* Assert a file exists on the remote storage system
97140
*
@@ -177,4 +220,18 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
177220
{
178221
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), $message);
179222
}
223+
224+
/**
225+
* Asserts that a directory on the remote storage system is empty
226+
*
227+
* @param string $path
228+
* @param string $message
229+
* @return void
230+
*
231+
* @throws \Magento\Framework\Exception\FileSystemException
232+
*/
233+
public function assertDirectoryEmpty($path, $message = ""): void
234+
{
235+
$this->assertEmpty($this->driver->readDirectory($path), $message);
236+
}
180237
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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="AdminAwsS3ImportBundleProductTest" extends="AdminImportBundleProductTest">
12+
<annotations>
13+
<features value="AwsS3"/>
14+
<stories value="Import Products"/>
15+
<title value="S3 - Import Bundle Product"/>
16+
<description value="Imports a .csv file containing a bundle product. Verifies that product is imported
17+
successfully and can be purchased."/>
18+
<severity value="MAJOR"/>
19+
<group value="importExport"/>
20+
<group value="Bundle"/>
21+
<group value="remote_storage_aws_s3"/>
22+
</annotations>
23+
24+
<before>
25+
<!-- Locally Copy Import Files to Unique Media Import Directory -->
26+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="createDirectory" stepKey="createDirectoryForImportFiles" after="createCustomer">
27+
<argument name="path">pub/media/import/{{ImportProduct_Bundle.name}}</argument>
28+
</helper>
29+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyImportFile" after="createDirectoryForImportFiles">
30+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Bundle.fileName}}</argument>
31+
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProduct_Bundle.fileName}}</argument>
32+
</helper>
33+
<remove keyForRemoval="createDirectoryForImportImages"/>
34+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct1BaseImage">
35+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple1_Bundle.baseImage}}</argument>
36+
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
37+
</helper>
38+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct2BaseImage">
39+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple2_Bundle.smallImage}}</argument>
40+
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
41+
</helper>
42+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct3BaseImage">
43+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
44+
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
45+
</helper>
46+
47+
<!-- Enable AWS S3 Remote Storage & Sync -->
48+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage" after="copyProduct3BaseImage"/>
49+
<magentoCLI command="remote-storage:sync" timeout="120" stepKey="syncRemoteStorage" after="enableRemoteStorage"/>
50+
51+
<!-- Copy to Import Directory in AWS S3 -->
52+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="createDirectory" stepKey="createDirectoryForImportFilesInS3" after="syncRemoteStorage">
53+
<argument name="path">var/import/images/{{ImportProduct_Bundle.name}}</argument>
54+
</helper>
55+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct1BaseImageInS3" after="createDirectoryForImportFilesInS3">
56+
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
57+
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
58+
</helper>
59+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct2BaseImageInS3" after="copyProduct1BaseImageInS3">
60+
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
61+
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
62+
</helper>
63+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct3BaseImageInS3" after="copyProduct2BaseImageInS3">
64+
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
65+
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
66+
</helper>
67+
</before>
68+
69+
<after>
70+
<!-- Delete S3 Data -->
71+
<remove keyForRemoval="deleteProductImageDirectory"/>
72+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryS3" after="deleteCustomer">
73+
<argument name="path">media/import/{{ImportProduct_Bundle.name}}</argument>
74+
</helper>
75+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
76+
<argument name="path">var/import/images/{{ImportProduct_Bundle.name}}</argument>
77+
</helper>
78+
79+
<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
80+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>
81+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryLocal" after="disableRemoteStorage">
82+
<argument name="path">pub/media/import/{{ImportProduct_Bundle.name}}</argument>
83+
</helper>
84+
</after>
85+
86+
<!-- Import Bundle Product -->
87+
<actionGroup ref="AdminFillImportFormActionGroup" stepKey="fillImportForm">
88+
<argument name="importFile" value="{{ImportProduct_Bundle.fileName}}"/>
89+
<argument name="imagesFileDirectory" value="{{ImportProduct_Bundle.name}}"/>
90+
</actionGroup>
91+
</test>
92+
</tests>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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="AdminAwsS3ImportDownloadableProductsWithFileLinksTest" extends="AdminImportDownloadableProductsWithFileLinksTest">
12+
<annotations>
13+
<features value="AwsS3"/>
14+
<stories value="Import Products"/>
15+
<title value="S3 - Import Downloadable Products with File Links"/>
16+
<description value="Imports a .csv file containing a downloadable product with file links. Verifies that
17+
products are imported successfully."/>
18+
<severity value="MAJOR"/>
19+
<group value="importExport"/>
20+
<group value="Downloadable"/>
21+
<group value="remote_storage_aws_s3"/>
22+
</annotations>
23+
24+
<before>
25+
<!-- Locally Copy Import Files to Unique Media Import Directory -->
26+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="createDirectory" stepKey="createDirectoryForImportFiles" after="createCustomer">
27+
<argument name="path">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
28+
</helper>
29+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyImportFile" after="createDirectoryForImportFiles">
30+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Downloadable_FileLinks.fileName}}</argument>
31+
<argument name="destination">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.fileName}}</argument>
32+
</helper>
33+
<remove keyForRemoval="createDirectoryForImportImages"/>
34+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyBaseImage">
35+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Downloadable_FileLinks.baseImage}}</argument>
36+
<argument name="destination">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.baseImage}}</argument>
37+
</helper>
38+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copySmallImage">
39+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Downloadable_FileLinks.smallImage}}</argument>
40+
<argument name="destination">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.smallImage}}</argument>
41+
</helper>
42+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyThumbnailImage">
43+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Downloadable_FileLinks.thumbnailImage}}</argument>
44+
<argument name="destination">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.thumbnailImage}}</argument>
45+
</helper>
46+
47+
<!-- Enable AWS S3 Remote Storage & Sync -->
48+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage" after="copyThumbnailImage"/>
49+
<magentoCLI command="remote-storage:sync" timeout="120" stepKey="syncRemoteStorage" after="enableRemoteStorage"/>
50+
51+
<!-- Copy to Import Directory in AWS S3 -->
52+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="createDirectory" stepKey="createDirectoryForImportFilesInS3" after="syncRemoteStorage">
53+
<argument name="path">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
54+
</helper>
55+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyBaseImageInS3" after="createDirectoryForImportFilesInS3">
56+
<argument name="source">media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.baseImage}}</argument>
57+
<argument name="destination">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.baseImage}}</argument>
58+
</helper>
59+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copySmallImageInS3" after="copyBaseImageInS3">
60+
<argument name="source">media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.smallImage}}</argument>
61+
<argument name="destination">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.smallImage}}</argument>
62+
</helper>
63+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyThumbnailImageInS3" after="copySmallImageInS3">
64+
<argument name="source">media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.thumbnailImage}}</argument>
65+
<argument name="destination">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.thumbnailImage}}</argument>
66+
</helper>
67+
</before>
68+
69+
<after>
70+
<!-- Delete S3 Data -->
71+
<remove keyForRemoval="deleteProductImageDirectory"/>
72+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryS3" after="deleteCustomer">
73+
<argument name="path">media/import/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
74+
</helper>
75+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
76+
<argument name="path">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
77+
</helper>
78+
79+
<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
80+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>
81+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryLocal" after="disableRemoteStorage">
82+
<argument name="path">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
83+
</helper>
84+
</after>
85+
86+
<!-- Import Downloadable Product -->
87+
<actionGroup ref="AdminFillImportFormActionGroup" stepKey="fillImportForm">
88+
<argument name="importFile" value="{{ImportProduct_Downloadable_FileLinks.fileName}}"/>
89+
<argument name="imagesFileDirectory" value="{{ImportProduct_Downloadable_FileLinks.name}}"/>
90+
</actionGroup>
91+
</test>
92+
</tests>

0 commit comments

Comments
 (0)