Skip to content

Commit 722b8b8

Browse files
Roman HaninRoman Hanin
authored andcommitted
Merge branch 'B2B-1610' of https://github.com/magento-arcticfoxes/magento2ce into B2B-1610
2 parents 6181861 + 25c6a36 commit 722b8b8

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
@@ -150,7 +150,7 @@ public function deleteDirectory($path): void
150150
*/
151151
public function assertFileExists($filePath, $message = ''): void
152152
{
153-
$this->assertTrue($this->driver->isExists($filePath), $message);
153+
$this->assertTrue($this->driver->isExists($filePath), "Failed asserting $filePath exists. " . $message);
154154
}
155155

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

171199
/**
@@ -191,9 +219,9 @@ public function assertFileDoesNotExist($filePath, $message = ''): void
191219
*
192220
* @throws \Magento\Framework\Exception\FileSystemException
193221
*/
194-
public function assertFileEmpty($filePath, $message = ""): void
222+
public function assertFileEmpty($filePath, $message = ''): void
195223
{
196-
$this->assertEmpty($this->driver->fileGetContents($filePath), $message);
224+
$this->assertEmpty($this->driver->fileGetContents($filePath), "Failed asserting $filePath is empty. " . $message);
197225
}
198226

199227
/**
@@ -205,9 +233,9 @@ public function assertFileEmpty($filePath, $message = ""): void
205233
*
206234
* @throws \Magento\Framework\Exception\FileSystemException
207235
*/
208-
public function assertFileNotEmpty($filePath, $message = ""): void
236+
public function assertFileNotEmpty($filePath, $message = ''): void
209237
{
210-
$this->assertNotEmpty($this->driver->fileGetContents($filePath), $message);
238+
$this->assertNotEmpty($this->driver->fileGetContents($filePath), "Failed asserting $filePath is not empty. " . $message);
211239
}
212240

213241
/**
@@ -220,9 +248,9 @@ public function assertFileNotEmpty($filePath, $message = ""): void
220248
*
221249
* @throws \Magento\Framework\Exception\FileSystemException
222250
*/
223-
public function assertFileContainsString($filePath, $text, $message = ""): void
251+
public function assertFileContainsString($filePath, $text, $message = ''): void
224252
{
225-
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), $message);
253+
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), "Failed asserting $filePath contains $text. " . $message);
226254
}
227255

228256
/**
@@ -237,10 +265,10 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
237265
*
238266
* @throws \Magento\Framework\Exception\FileSystemException
239267
*/
240-
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ""): void
268+
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ''): void
241269
{
242270
$files = $this->driver->search($pattern, $path);
243-
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), $message);
271+
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), "Failed asserting file of index \"$fileIndex\" matching glob pattern \"$pattern\" at location \"$path\" contains $text. " . $message);
244272
}
245273

246274
/**
@@ -253,9 +281,9 @@ public function assertGlobbedFileContainsString($path, $pattern, $text, $fileInd
253281
*
254282
* @throws \Magento\Framework\Exception\FileSystemException
255283
*/
256-
public function assertFileDoesNotContain($filePath, $text, $message = ""): void
284+
public function assertFileDoesNotContainString($filePath, $text, $message = ''): void
257285
{
258-
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), $message);
286+
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), "Failed asserting $filePath does not contain $text. " . $message);
259287
}
260288

261289
/**
@@ -267,8 +295,22 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
267295
*
268296
* @throws \Magento\Framework\Exception\FileSystemException
269297
*/
270-
public function assertDirectoryEmpty($path, $message = ""): void
298+
public function assertDirectoryEmpty($path, $message = ''): void
299+
{
300+
$this->assertEmpty($this->driver->readDirectory($path), "Failed asserting $path is empty. " . $message);
301+
}
302+
303+
/**
304+
* Asserts that a directory on the remote storage system is not empty
305+
*
306+
* @param string $path
307+
* @param string $message
308+
* @return void
309+
*
310+
* @throws \Magento\Framework\Exception\FileSystemException
311+
*/
312+
public function assertDirectoryNotEmpty($path, $message = ''): void
271313
{
272-
$this->assertEmpty($this->driver->readDirectory($path), $message);
314+
$this->assertNotEmpty($this->driver->readDirectory($path), "Failed asserting $path is not empty. " . $message);
273315
}
274316
}
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)