Skip to content

Commit

Permalink
Merge branch '2.4-develop' into MC-41439
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel da Gama authored Apr 1, 2021
2 parents 5f93692 + be82efb commit bf6cd90
Show file tree
Hide file tree
Showing 346 changed files with 6,057 additions and 1,001 deletions.
72 changes: 57 additions & 15 deletions app/code/Magento/AwsS3/Test/Mftf/Helper/S3FileAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function deleteDirectory($path): void
*/
public function assertFileExists($filePath, $message = ''): void
{
$this->assertTrue($this->driver->isExists($filePath), $message);
$this->assertTrue($this->driver->isExists($filePath), "Failed asserting $filePath exists. " . $message);
}

/**
Expand All @@ -158,10 +158,38 @@ public function assertFileExists($filePath, $message = ''): void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertGlobbedFileExists($path, $pattern, $message = ""): void
public function assertGlobbedFileExists($path, $pattern, $message = ''): void
{
$files = $this->driver->search($pattern, $path);
$this->assertNotEmpty($files, $message);
$this->assertNotEmpty($files, "Failed asserting file matching glob pattern \"$pattern\" at location \"$path\" is not empty. " . $message);
}

/**
* Asserts that a file or directory exists on the remote storage system
*
* @param string $path
* @param string $message
* @return void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertPathExists($path, $message = ''): void
{
$this->assertTrue($this->driver->isExists($path), "Failed asserting $path exists. " . $message);
}

/**
* Asserts that a file or directory does not exist on the remote storage system
*
* @param string $path
* @param string $message
* @return void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertPathDoesNotExist($path, $message = ''): void
{
$this->assertFalse($this->driver->isExists($path), "Failed asserting $path does not exist. " . $message);
}

/**
Expand All @@ -187,9 +215,9 @@ public function assertFileDoesNotExist($filePath, $message = ''): void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertFileEmpty($filePath, $message = ""): void
public function assertFileEmpty($filePath, $message = ''): void
{
$this->assertEmpty($this->driver->fileGetContents($filePath), $message);
$this->assertEmpty($this->driver->fileGetContents($filePath), "Failed asserting $filePath is empty. " . $message);
}

/**
Expand All @@ -201,9 +229,9 @@ public function assertFileEmpty($filePath, $message = ""): void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertFileNotEmpty($filePath, $message = ""): void
public function assertFileNotEmpty($filePath, $message = ''): void
{
$this->assertNotEmpty($this->driver->fileGetContents($filePath), $message);
$this->assertNotEmpty($this->driver->fileGetContents($filePath), "Failed asserting $filePath is not empty. " . $message);
}

/**
Expand All @@ -216,9 +244,9 @@ public function assertFileNotEmpty($filePath, $message = ""): void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertFileContainsString($filePath, $text, $message = ""): void
public function assertFileContainsString($filePath, $text, $message = ''): void
{
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), $message);
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), "Failed asserting $filePath contains $text. " . $message);
}

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

/**
Expand All @@ -249,9 +277,9 @@ public function assertGlobbedFileContainsString($path, $pattern, $text, $fileInd
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertFileDoesNotContain($filePath, $text, $message = ""): void
public function assertFileDoesNotContainString($filePath, $text, $message = ''): void
{
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), $message);
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), "Failed asserting $filePath does not contain $text. " . $message);
}

/**
Expand All @@ -263,8 +291,22 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertDirectoryEmpty($path, $message = ""): void
public function assertDirectoryEmpty($path, $message = ''): void
{
$this->assertEmpty($this->driver->readDirectory($path), "Failed asserting $path is empty. " . $message);
}

/**
* Asserts that a directory on the remote storage system is not empty
*
* @param string $path
* @param string $message
* @return void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertDirectoryNotEmpty($path, $message = ''): void
{
$this->assertEmpty($this->driver->readDirectory($path), $message);
$this->assertNotEmpty($this->driver->readDirectory($path), "Failed asserting $path is not empty. " . $message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminAwsS3ExportBundleProductTest" extends="AdminExportBundleProductTest">
<annotations>
<features value="AwsS3"/>
<stories value="Export Products"/>
<title value="S3 - Export Bundle Products"/>
<description value="Verifies that a user can export Bundle and Simple child products for Bundled products
with a dynamic price, a fixed price, and a custom attribute. Verifies that the exported file and the
downloadable copy of the exported file contain the expected products. Note that MFTF cannot simply download
a file and have access to it due to the test not having access to the server that is running the test
browser. Therefore, this test verifies that the Download button can be successfully clicked, grabs the
request URL from the Download button, executes the request on the magento machine via a curl request, and
verifies the contents of the downloaded file. Uses S3 for the file system."/>
<severity value="CRITICAL"/>
<testCaseId value="MC-38558"/>
<group value="importExport"/>
<group value="remote_storage_aws_s3"/>
</annotations>

<before>
<!-- Enable AWS S3 Remote Storage -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage" before="firstSimpleProductForDynamic"/>
</before>

<after>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteExportFileDirectory">
<argument name="path">import_export/export</argument>
</helper>

<!-- Disable AWS S3 Remote Storage -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logout"/>
</after>

<!-- Validate Export File on File System: Dynamic Bundle Product -->
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileExists" stepKey="assertExportFileExists">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFirstSimpleProductForDynamicBundledProduct">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$firstSimpleProductForDynamic.name$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsSecondSimpleProductForDynamicBundledProduct">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$secondSimpleProductForDynamic.name$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsDynamicBundleProduct">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$createDynamicBundleProduct.name$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsDynamicBundleProductOption1">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">name=$createFirstBundleOption.option[title]$,type=$createFirstBundleOption.option[type]$,required=$createFirstBundleOption.option[required]$,sku=$$firstSimpleProductForDynamic.sku$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsDynamicBundleProductOption2">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">name=$createFirstBundleOption.option[title]$,type=$createFirstBundleOption.option[type]$,required=$createFirstBundleOption.option[required]$,sku=$$secondSimpleProductForDynamic.sku$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsDynamicPriceBundleProduct">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">0.000000,,,,$$createDynamicBundleProduct.sku$$</argument>
</helper>

<!-- Validate Export File on File System: Fixed Bundle Product -->
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFirstSimpleProductForFixedBundledProduct">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$firstSimpleProductForFixed.name$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsSecondSimpleProductForFixedBundledProduct">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$secondSimpleProductForFixed.name$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProduct">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$createFixedBundleProduct.name$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProductOption1">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">name=$createSecondBundleOption.option[title]$,type=$createSecondBundleOption.option[type]$,required=$createSecondBundleOption.option[required]$,sku=$$firstSimpleProductForFixed.sku$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProductOption2">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">name=$createSecondBundleOption.option[title]$,type=$createSecondBundleOption.option[type]$,required=$createSecondBundleOption.option[required]$,sku=$$secondSimpleProductForFixed.sku$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedPriceBundleProduct">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$createFixedBundleProduct.price$$0000,,,,$$createFixedBundleProduct.sku$$</argument>
</helper>

<!-- Validate Export File on File System: Fixed Bundle Product with Attribute -->
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFirstSimpleProductForFixedBundledProductWithAttribute">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$firstSimpleProductForFixedWithAttribute.name$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsSecondSimpleProductForFixedBundledProductWithAttribute">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$secondSimpleProductForFixedWithAttribute.name$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProductWithAttribute">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$createFixedBundleProductWithAttribute.name$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProductWithAttributeOption1">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">name=$createBundleOptionWithAttribute.option[title]$,type=$createBundleOptionWithAttribute.option[type]$,required=$createBundleOptionWithAttribute.option[required]$,sku=$$firstSimpleProductForFixedWithAttribute.sku$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedBundleProductWithAttributeOption2">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">name=$createBundleOptionWithAttribute.option[title]$,type=$createBundleOptionWithAttribute.option[type]$,required=$createBundleOptionWithAttribute.option[required]$,sku=$$secondSimpleProductForFixedWithAttribute.sku$$</argument>
</helper>
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsFixedPriceBundleProductWithAttribute">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
<argument name="text">$$createFixedBundleProductWithAttribute.price$$0000,,,,$$createFixedBundleProductWithAttribute.sku$$</argument>
</helper>

<!-- Delete Export File -->
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="assertFileDoesNotExist" stepKey="assertExportFileDeleted">
<argument name="filePath">import_export/export/{$grabNameFile}</argument>
</helper>
</test>
</tests>
Loading

0 comments on commit bf6cd90

Please sign in to comment.