Skip to content

Commit

Permalink
Merge branch 'bugfix/email-tempalte-filter-not-returning-string' of g…
Browse files Browse the repository at this point in the history
…ithub.com:Skullsneeze/magento2 into bugfix/email-tempalte-filter-not-returning-string
  • Loading branch information
Martijn Swinkels committed Feb 26, 2021
2 parents 4b46634 + 28e0124 commit db048d2
Show file tree
Hide file tree
Showing 395 changed files with 11,120 additions and 1,742 deletions.
57 changes: 57 additions & 0 deletions app/code/Magento/AwsS3/Test/Mftf/Helper/S3FileAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,49 @@ public function deleteFileIfExists($filePath): void
}
}

/**
* Copy source into destination
*
* @param string $source
* @param string $destination
* @return void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function copy($source, $destination): void
{
$this->driver->copy($source, $destination);
}

/**
* Create directory in the S3 bucket
*
* @param string $path
* @param int $permissions
* @return void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function createDirectory($path, $permissions = 0777): void
{
$this->driver->createDirectory($path, $permissions);
}

/**
* Recursive delete directory in the S3 bucket
*
* @param string $path
* @return void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function deleteDirectory($path): void
{
if ($this->driver->isExists($path)) {
$this->driver->deleteDirectory($path);
}
}

/**
* Assert a file exists on the remote storage system
*
Expand Down Expand Up @@ -177,4 +220,18 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
{
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), $message);
}

/**
* Asserts that a directory on the remote storage system is empty
*
* @param string $path
* @param string $message
* @return void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertDirectoryEmpty($path, $message = ""): void
{
$this->assertEmpty($this->driver->readDirectory($path), $message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?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="AdminAwsS3ImportBundleProductTest" extends="AdminImportBundleProductTest">
<annotations>
<features value="AwsS3"/>
<stories value="Import Products"/>
<title value="S3 - Import Bundle Product"/>
<description value="Imports a .csv file containing a bundle product. Verifies that product is imported
successfully and can be purchased."/>
<severity value="MAJOR"/>
<group value="importExport"/>
<group value="Bundle"/>
<group value="remote_storage_aws_s3"/>
</annotations>

<before>
<!-- Locally Copy Import Files to Unique Media Import Directory -->
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="createDirectory" stepKey="createDirectoryForImportFiles" after="createCustomer">
<argument name="path">pub/media/import/{{ImportProduct_Bundle.name}}</argument>
</helper>
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyImportFile" after="createDirectoryForImportFiles">
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Bundle.fileName}}</argument>
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProduct_Bundle.fileName}}</argument>
</helper>
<remove keyForRemoval="createDirectoryForImportImages"/>
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct1BaseImage">
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple1_Bundle.baseImage}}</argument>
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
</helper>
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct2BaseImage">
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple2_Bundle.smallImage}}</argument>
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
</helper>
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct3BaseImage">
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
</helper>

<!-- Enable AWS S3 Remote Storage & Sync -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage" after="copyProduct3BaseImage"/>
<magentoCLI command="remote-storage:sync" timeout="120" stepKey="syncRemoteStorage" after="enableRemoteStorage"/>

<!-- Copy to Import Directory in AWS S3 -->
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="createDirectory" stepKey="createDirectoryForImportFilesInS3" after="syncRemoteStorage">
<argument name="path">var/import/images/{{ImportProduct_Bundle.name}}</argument>
</helper>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct1BaseImageInS3" after="createDirectoryForImportFilesInS3">
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
</helper>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct2BaseImageInS3" after="copyProduct1BaseImageInS3">
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
</helper>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct3BaseImageInS3" after="copyProduct2BaseImageInS3">
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
</helper>
</before>

<after>
<!-- Delete S3 Data -->
<remove keyForRemoval="deleteProductImageDirectory"/>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryS3" after="deleteCustomer">
<argument name="path">media/import/{{ImportProduct_Bundle.name}}</argument>
</helper>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
<argument name="path">var/import/images/{{ImportProduct_Bundle.name}}</argument>
</helper>

<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryLocal" after="disableRemoteStorage">
<argument name="path">pub/media/import/{{ImportProduct_Bundle.name}}</argument>
</helper>
</after>

<!-- Import Bundle Product -->
<actionGroup ref="AdminFillImportFormActionGroup" stepKey="fillImportForm">
<argument name="importFile" value="{{ImportProduct_Bundle.fileName}}"/>
<argument name="imagesFileDirectory" value="{{ImportProduct_Bundle.name}}"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?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="AdminAwsS3ImportDownloadableProductsWithFileLinksTest" extends="AdminImportDownloadableProductsWithFileLinksTest">
<annotations>
<features value="AwsS3"/>
<stories value="Import Products"/>
<title value="S3 - Import Downloadable Products with File Links"/>
<description value="Imports a .csv file containing a downloadable product with file links. Verifies that
products are imported successfully."/>
<severity value="MAJOR"/>
<group value="importExport"/>
<group value="Downloadable"/>
<group value="remote_storage_aws_s3"/>
</annotations>

<before>
<!-- Locally Copy Import Files to Unique Media Import Directory -->
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="createDirectory" stepKey="createDirectoryForImportFiles" after="createCustomer">
<argument name="path">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
</helper>
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyImportFile" after="createDirectoryForImportFiles">
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Downloadable_FileLinks.fileName}}</argument>
<argument name="destination">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.fileName}}</argument>
</helper>
<remove keyForRemoval="createDirectoryForImportImages"/>
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyBaseImage">
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Downloadable_FileLinks.baseImage}}</argument>
<argument name="destination">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.baseImage}}</argument>
</helper>
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copySmallImage">
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Downloadable_FileLinks.smallImage}}</argument>
<argument name="destination">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.smallImage}}</argument>
</helper>
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyThumbnailImage">
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Downloadable_FileLinks.thumbnailImage}}</argument>
<argument name="destination">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.thumbnailImage}}</argument>
</helper>

<!-- Enable AWS S3 Remote Storage & Sync -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage" after="copyThumbnailImage"/>
<magentoCLI command="remote-storage:sync" timeout="120" stepKey="syncRemoteStorage" after="enableRemoteStorage"/>

<!-- Copy to Import Directory in AWS S3 -->
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="createDirectory" stepKey="createDirectoryForImportFilesInS3" after="syncRemoteStorage">
<argument name="path">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
</helper>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyBaseImageInS3" after="createDirectoryForImportFilesInS3">
<argument name="source">media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.baseImage}}</argument>
<argument name="destination">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.baseImage}}</argument>
</helper>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copySmallImageInS3" after="copyBaseImageInS3">
<argument name="source">media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.smallImage}}</argument>
<argument name="destination">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.smallImage}}</argument>
</helper>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyThumbnailImageInS3" after="copySmallImageInS3">
<argument name="source">media/import/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.thumbnailImage}}</argument>
<argument name="destination">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}/{{ImportProduct_Downloadable_FileLinks.thumbnailImage}}</argument>
</helper>
</before>

<after>
<!-- Delete S3 Data -->
<remove keyForRemoval="deleteProductImageDirectory"/>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryS3" after="deleteCustomer">
<argument name="path">media/import/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
</helper>
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
<argument name="path">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
</helper>

<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryLocal" after="disableRemoteStorage">
<argument name="path">pub/media/import/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
</helper>
</after>

<!-- Import Downloadable Product -->
<actionGroup ref="AdminFillImportFormActionGroup" stepKey="fillImportForm">
<argument name="importFile" value="{{ImportProduct_Downloadable_FileLinks.fileName}}"/>
<argument name="imagesFileDirectory" value="{{ImportProduct_Downloadable_FileLinks.name}}"/>
</actionGroup>
</test>
</tests>
Loading

0 comments on commit db048d2

Please sign in to comment.