Skip to content

Commit 29ef0d6

Browse files
committed
Merge branch 'B2B-1754' into foxes-pr
2 parents fcb4f0e + df49b9f commit 29ef0d6

File tree

25 files changed

+549
-150
lines changed

25 files changed

+549
-150
lines changed

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

Lines changed: 47 additions & 19 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,24 +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);
165165
}
166166

167167
/**
168-
* Assert a file does not exist on the remote storage system
168+
* Asserts that a file or directory exists on the remote storage system
169169
*
170-
* @param string $filePath
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
171185
* @param string $message
172186
* @return void
173187
*
174188
* @throws \Magento\Framework\Exception\FileSystemException
175189
*/
176-
public function assertFileDoesNotExist($filePath, $message = ''): void
190+
public function assertPathDoesNotExist($path, $message = ''): void
177191
{
178-
$this->assertFalse($this->driver->isExists($filePath), $message);
192+
$this->assertFalse($this->driver->isExists($path), "Failed asserting $path does not exist. " . $message);
179193
}
180194

181195
/**
@@ -187,9 +201,9 @@ public function assertFileDoesNotExist($filePath, $message = ''): void
187201
*
188202
* @throws \Magento\Framework\Exception\FileSystemException
189203
*/
190-
public function assertFileEmpty($filePath, $message = ""): void
204+
public function assertFileEmpty($filePath, $message = ''): void
191205
{
192-
$this->assertEmpty($this->driver->fileGetContents($filePath), $message);
206+
$this->assertEmpty($this->driver->fileGetContents($filePath), "Failed asserting $filePath is empty. " . $message);
193207
}
194208

195209
/**
@@ -201,9 +215,9 @@ public function assertFileEmpty($filePath, $message = ""): void
201215
*
202216
* @throws \Magento\Framework\Exception\FileSystemException
203217
*/
204-
public function assertFileNotEmpty($filePath, $message = ""): void
218+
public function assertFileNotEmpty($filePath, $message = ''): void
205219
{
206-
$this->assertNotEmpty($this->driver->fileGetContents($filePath), $message);
220+
$this->assertNotEmpty($this->driver->fileGetContents($filePath), "Failed asserting $filePath is not empty. " . $message);
207221
}
208222

209223
/**
@@ -216,9 +230,9 @@ public function assertFileNotEmpty($filePath, $message = ""): void
216230
*
217231
* @throws \Magento\Framework\Exception\FileSystemException
218232
*/
219-
public function assertFileContainsString($filePath, $text, $message = ""): void
233+
public function assertFileContainsString($filePath, $text, $message = ''): void
220234
{
221-
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), $message);
235+
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), "Failed asserting $filePath contains $text. " . $message);
222236
}
223237

224238
/**
@@ -233,10 +247,10 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
233247
*
234248
* @throws \Magento\Framework\Exception\FileSystemException
235249
*/
236-
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ""): void
250+
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ''): void
237251
{
238252
$files = $this->driver->search($pattern, $path);
239-
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), $message);
253+
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), "Failed asserting file of index \"$fileIndex\" matching glob pattern \"$pattern\" at location \"$path\" contains $text. " . $message);
240254
}
241255

242256
/**
@@ -264,9 +278,9 @@ public function assertFileDoesNotContainString($filePath, $text, $message = ""):
264278
*
265279
* @throws \Magento\Framework\Exception\FileSystemException
266280
*/
267-
public function assertFileDoesNotContain($filePath, $text, $message = ""): void
281+
public function assertFileDoesNotContain($filePath, $text, $message = ''): void
268282
{
269-
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), $message);
283+
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), "Failed asserting $filePath does not contain $text. " . $message);
270284
}
271285

272286
/**
@@ -278,8 +292,22 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
278292
*
279293
* @throws \Magento\Framework\Exception\FileSystemException
280294
*/
281-
public function assertDirectoryEmpty($path, $message = ""): void
295+
public function assertDirectoryEmpty($path, $message = ''): void
296+
{
297+
$this->assertEmpty($this->driver->readDirectory($path), "Failed asserting $path is empty. " . $message);
298+
}
299+
300+
/**
301+
* Asserts that a directory on the remote storage system is not empty
302+
*
303+
* @param string $path
304+
* @param string $message
305+
* @return void
306+
*
307+
* @throws \Magento\Framework\Exception\FileSystemException
308+
*/
309+
public function assertDirectoryNotEmpty($path, $message = ''): void
282310
{
283-
$this->assertEmpty($this->driver->readDirectory($path), $message);
311+
$this->assertNotEmpty($this->driver->readDirectory($path), "Failed asserting $path is not empty. " . $message);
284312
}
285313
}

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ImportBundleProductTest.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@
2323

2424
<before>
2525
<!-- Locally Copy Import Files to Unique Media Import Directory -->
26-
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="createDirectory" stepKey="createDirectoryForImportFiles" after="createCustomer">
26+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="createDirectory" stepKey="createDirectoryForImportFiles" after="createCustomer">
2727
<argument name="path">pub/media/import/{{ImportProduct_Bundle.name}}</argument>
2828
</helper>
29-
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyImportFile" after="createDirectoryForImportFiles">
29+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyImportFile" after="createDirectoryForImportFiles">
3030
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Bundle.fileName}}</argument>
3131
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProduct_Bundle.fileName}}</argument>
3232
</helper>
3333
<remove keyForRemoval="createDirectoryForImportImages"/>
34-
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct1BaseImage">
34+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct1BaseImage">
3535
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple1_Bundle.baseImage}}</argument>
3636
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
3737
</helper>
38-
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct2BaseImage">
38+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct2BaseImage">
3939
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple2_Bundle.smallImage}}</argument>
4040
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
4141
</helper>
42-
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct3BaseImage">
42+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct3BaseImage">
4343
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
4444
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
4545
</helper>
@@ -49,18 +49,18 @@
4949
<magentoCLI command="remote-storage:sync" timeout="120" stepKey="syncRemoteStorage" after="enableRemoteStorage"/>
5050

5151
<!-- Copy to Import Directory in AWS S3 -->
52-
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="createDirectory" stepKey="createDirectoryForImportFilesInS3" after="syncRemoteStorage">
52+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="createDirectory" stepKey="createDirectoryForImportFilesInS3" after="syncRemoteStorage">
5353
<argument name="path">var/import/images/{{ImportProduct_Bundle.name}}</argument>
5454
</helper>
55-
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct1BaseImageInS3" after="createDirectoryForImportFilesInS3">
55+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct1BaseImageInS3" after="createDirectoryForImportFilesInS3">
5656
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
5757
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
5858
</helper>
59-
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct2BaseImageInS3" after="copyProduct1BaseImageInS3">
59+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct2BaseImageInS3" after="copyProduct1BaseImageInS3">
6060
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
6161
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
6262
</helper>
63-
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct3BaseImageInS3" after="copyProduct2BaseImageInS3">
63+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct3BaseImageInS3" after="copyProduct2BaseImageInS3">
6464
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
6565
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
6666
</helper>
@@ -69,16 +69,16 @@
6969
<after>
7070
<!-- Delete S3 Data -->
7171
<remove keyForRemoval="deleteProductImageDirectory"/>
72-
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryS3" after="deleteCustomer">
72+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryS3" after="deleteCustomer">
7373
<argument name="path">media/import/{{ImportProduct_Bundle.name}}</argument>
7474
</helper>
75-
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
75+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
7676
<argument name="path">var/import/images/{{ImportProduct_Bundle.name}}</argument>
7777
</helper>
7878

7979
<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
8080
<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">
81+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryLocal" after="disableRemoteStorage">
8282
<argument name="path">pub/media/import/{{ImportProduct_Bundle.name}}</argument>
8383
</helper>
8484
</after>

0 commit comments

Comments
 (0)