Skip to content

Commit 81672a2

Browse files
authored
Merge pull request #6703 from magento-arcticfoxes/foxes-pr
[arcticfoxes] PRs
2 parents a369628 + ff34f52 commit 81672a2

File tree

272 files changed

+2224
-580
lines changed

Some content is hidden

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

272 files changed

+2224
-580
lines changed

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

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function deleteDirectory($path): void
146146
*/
147147
public function assertFileExists($filePath, $message = ''): void
148148
{
149-
$this->assertTrue($this->driver->isExists($filePath), $message);
149+
$this->assertTrue($this->driver->isExists($filePath), "Failed asserting $filePath exists. " . $message);
150150
}
151151

152152
/**
@@ -158,10 +158,38 @@ public function assertFileExists($filePath, $message = ''): void
158158
*
159159
* @throws \Magento\Framework\Exception\FileSystemException
160160
*/
161-
public function assertGlobbedFileExists($path, $pattern, $message = ""): void
161+
public function assertGlobbedFileExists($path, $pattern, $message = ''): void
162162
{
163163
$files = $this->driver->search($pattern, $path);
164-
$this->assertNotEmpty($files, $message);
164+
$this->assertNotEmpty($files, "Failed asserting file matching glob pattern \"$pattern\" at location \"$path\" is not empty. " . $message);
165+
}
166+
167+
/**
168+
* Asserts that a file or directory exists on the remote storage system
169+
*
170+
* @param string $path
171+
* @param string $message
172+
* @return void
173+
*
174+
* @throws \Magento\Framework\Exception\FileSystemException
175+
*/
176+
public function assertPathExists($path, $message = ''): void
177+
{
178+
$this->assertTrue($this->driver->isExists($path), "Failed asserting $path exists. " . $message);
179+
}
180+
181+
/**
182+
* Asserts that a file or directory does not exist on the remote storage system
183+
*
184+
* @param string $path
185+
* @param string $message
186+
* @return void
187+
*
188+
* @throws \Magento\Framework\Exception\FileSystemException
189+
*/
190+
public function assertPathDoesNotExist($path, $message = ''): void
191+
{
192+
$this->assertFalse($this->driver->isExists($path), "Failed asserting $path does not exist. " . $message);
165193
}
166194

167195
/**
@@ -187,9 +215,9 @@ public function assertFileDoesNotExist($filePath, $message = ''): void
187215
*
188216
* @throws \Magento\Framework\Exception\FileSystemException
189217
*/
190-
public function assertFileEmpty($filePath, $message = ""): void
218+
public function assertFileEmpty($filePath, $message = ''): void
191219
{
192-
$this->assertEmpty($this->driver->fileGetContents($filePath), $message);
220+
$this->assertEmpty($this->driver->fileGetContents($filePath), "Failed asserting $filePath is empty. " . $message);
193221
}
194222

195223
/**
@@ -201,9 +229,9 @@ public function assertFileEmpty($filePath, $message = ""): void
201229
*
202230
* @throws \Magento\Framework\Exception\FileSystemException
203231
*/
204-
public function assertFileNotEmpty($filePath, $message = ""): void
232+
public function assertFileNotEmpty($filePath, $message = ''): void
205233
{
206-
$this->assertNotEmpty($this->driver->fileGetContents($filePath), $message);
234+
$this->assertNotEmpty($this->driver->fileGetContents($filePath), "Failed asserting $filePath is not empty. " . $message);
207235
}
208236

209237
/**
@@ -216,9 +244,9 @@ public function assertFileNotEmpty($filePath, $message = ""): void
216244
*
217245
* @throws \Magento\Framework\Exception\FileSystemException
218246
*/
219-
public function assertFileContainsString($filePath, $text, $message = ""): void
247+
public function assertFileContainsString($filePath, $text, $message = ''): void
220248
{
221-
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), $message);
249+
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), "Failed asserting $filePath contains $text. " . $message);
222250
}
223251

224252
/**
@@ -233,10 +261,10 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
233261
*
234262
* @throws \Magento\Framework\Exception\FileSystemException
235263
*/
236-
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ""): void
264+
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ''): void
237265
{
238266
$files = $this->driver->search($pattern, $path);
239-
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), $message);
267+
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), "Failed asserting file of index \"$fileIndex\" matching glob pattern \"$pattern\" at location \"$path\" contains $text. " . $message);
240268
}
241269

242270
/**
@@ -249,9 +277,9 @@ public function assertGlobbedFileContainsString($path, $pattern, $text, $fileInd
249277
*
250278
* @throws \Magento\Framework\Exception\FileSystemException
251279
*/
252-
public function assertFileDoesNotContain($filePath, $text, $message = ""): void
280+
public function assertFileDoesNotContainString($filePath, $text, $message = ''): void
253281
{
254-
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), $message);
282+
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), "Failed asserting $filePath does not contain $text. " . $message);
255283
}
256284

257285
/**
@@ -263,8 +291,22 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
263291
*
264292
* @throws \Magento\Framework\Exception\FileSystemException
265293
*/
266-
public function assertDirectoryEmpty($path, $message = ""): void
294+
public function assertDirectoryEmpty($path, $message = ''): void
295+
{
296+
$this->assertEmpty($this->driver->readDirectory($path), "Failed asserting $path is empty. " . $message);
297+
}
298+
299+
/**
300+
* Asserts that a directory on the remote storage system is not empty
301+
*
302+
* @param string $path
303+
* @param string $message
304+
* @return void
305+
*
306+
* @throws \Magento\Framework\Exception\FileSystemException
307+
*/
308+
public function assertDirectoryNotEmpty($path, $message = ''): void
267309
{
268-
$this->assertEmpty($this->driver->readDirectory($path), $message);
310+
$this->assertNotEmpty($this->driver->readDirectory($path), "Failed asserting $path is not empty. " . $message);
269311
}
270312
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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="AdminAwsS3ExportBundleProductTest" extends="AdminExportBundleProductTest">
12+
<annotations>
13+
<features value="AwsS3"/>
14+
<stories value="Export Products"/>
15+
<title value="S3 - Export Bundle Products"/>
16+
<description value="Verifies that a user can export Bundle and Simple child products for Bundled products
17+
with a dynamic price, a fixed price, and a custom attribute. Verifies that the exported file and the
18+
downloadable copy of the exported file contain the expected products. Note that MFTF cannot simply download
19+
a file and have access to it due to the test not having access to the server that is running the test
20+
browser. Therefore, this test verifies that the Download button can be successfully clicked, grabs the
21+
request URL from the Download button, executes the request on the magento machine via a curl request, and
22+
verifies the contents of the downloaded file. Uses S3 for the file system."/>
23+
<severity value="CRITICAL"/>
24+
<testCaseId value="MC-38558"/>
25+
<group value="importExport"/>
26+
<group value="remote_storage_aws_s3"/>
27+
</annotations>
28+
29+
<before>
30+
<!-- Enable AWS S3 Remote Storage -->
31+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage" before="firstSimpleProductForDynamic"/>
32+
</before>
33+
34+
<after>
35+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteExportFileDirectory">
36+
<argument name="path">import_export/export</argument>
37+
</helper>
38+
39+
<!-- Disable AWS S3 Remote Storage -->
40+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logout"/>
41+
</after>
42+
43+
<!-- Validate Export File on File System: Dynamic Bundle Product -->
44+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileExists" stepKey="assertExportFileExists">
45+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
46+
</helper>
47+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFirstSimpleProductForDynamicBundledProduct">
48+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
49+
<argument name="text">$$firstSimpleProductForDynamic.name$$</argument>
50+
</helper>
51+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsSecondSimpleProductForDynamicBundledProduct">
52+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
53+
<argument name="text">$$secondSimpleProductForDynamic.name$$</argument>
54+
</helper>
55+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsDynamicBundleProduct">
56+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
57+
<argument name="text">$$createDynamicBundleProduct.name$$</argument>
58+
</helper>
59+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsDynamicBundleProductOption1">
60+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
61+
<argument name="text">name=$createFirstBundleOption.option[title]$,type=$createFirstBundleOption.option[type]$,required=$createFirstBundleOption.option[required]$,sku=$$firstSimpleProductForDynamic.sku$$</argument>
62+
</helper>
63+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsDynamicBundleProductOption2">
64+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
65+
<argument name="text">name=$createFirstBundleOption.option[title]$,type=$createFirstBundleOption.option[type]$,required=$createFirstBundleOption.option[required]$,sku=$$secondSimpleProductForDynamic.sku$$</argument>
66+
</helper>
67+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsDynamicPriceBundleProduct">
68+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
69+
<argument name="text">0.000000,,,,$$createDynamicBundleProduct.sku$$</argument>
70+
</helper>
71+
72+
<!-- Validate Export File on File System: Fixed Bundle Product -->
73+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFirstSimpleProductForFixedBundledProduct">
74+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
75+
<argument name="text">$$firstSimpleProductForFixed.name$$</argument>
76+
</helper>
77+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsSecondSimpleProductForFixedBundledProduct">
78+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
79+
<argument name="text">$$secondSimpleProductForFixed.name$$</argument>
80+
</helper>
81+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProduct">
82+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
83+
<argument name="text">$$createFixedBundleProduct.name$$</argument>
84+
</helper>
85+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProductOption1">
86+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
87+
<argument name="text">name=$createSecondBundleOption.option[title]$,type=$createSecondBundleOption.option[type]$,required=$createSecondBundleOption.option[required]$,sku=$$firstSimpleProductForFixed.sku$$</argument>
88+
</helper>
89+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProductOption2">
90+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
91+
<argument name="text">name=$createSecondBundleOption.option[title]$,type=$createSecondBundleOption.option[type]$,required=$createSecondBundleOption.option[required]$,sku=$$secondSimpleProductForFixed.sku$$</argument>
92+
</helper>
93+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedPriceBundleProduct">
94+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
95+
<argument name="text">$$createFixedBundleProduct.price$$0000,,,,$$createFixedBundleProduct.sku$$</argument>
96+
</helper>
97+
98+
<!-- Validate Export File on File System: Fixed Bundle Product with Attribute -->
99+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFirstSimpleProductForFixedBundledProductWithAttribute">
100+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
101+
<argument name="text">$$firstSimpleProductForFixedWithAttribute.name$$</argument>
102+
</helper>
103+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsSecondSimpleProductForFixedBundledProductWithAttribute">
104+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
105+
<argument name="text">$$secondSimpleProductForFixedWithAttribute.name$$</argument>
106+
</helper>
107+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProductWithAttribute">
108+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
109+
<argument name="text">$$createFixedBundleProductWithAttribute.name$$</argument>
110+
</helper>
111+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProductWithAttributeOption1">
112+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
113+
<argument name="text">name=$createBundleOptionWithAttribute.option[title]$,type=$createBundleOptionWithAttribute.option[type]$,required=$createBundleOptionWithAttribute.option[required]$,sku=$$firstSimpleProductForFixedWithAttribute.sku$$</argument>
114+
</helper>
115+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProductWithAttributeOption2">
116+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
117+
<argument name="text">name=$createBundleOptionWithAttribute.option[title]$,type=$createBundleOptionWithAttribute.option[type]$,required=$createBundleOptionWithAttribute.option[required]$,sku=$$secondSimpleProductForFixedWithAttribute.sku$$</argument>
118+
</helper>
119+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedPriceBundleProductWithAttribute">
120+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
121+
<argument name="text">$$createFixedBundleProductWithAttribute.price$$0000,,,,$$createFixedBundleProductWithAttribute.sku$$</argument>
122+
</helper>
123+
124+
<!-- Delete Export File -->
125+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileDoesNotExist" stepKey="assertExportFileDeleted">
126+
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
127+
</helper>
128+
</test>
129+
</tests>

0 commit comments

Comments
 (0)