Skip to content

Commit a653afd

Browse files
committed
Merge remote-tracking branch 'arcticfoxes/B2B-1632' into 2.4-develop-pr
2 parents 7a72b6b + 0fa62d0 commit a653afd

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@ public function assertFileExists($filePath, $message = ''): void
149149
$this->assertTrue($this->driver->isExists($filePath), $message);
150150
}
151151

152+
/**
153+
* Asserts that a file with the given glob pattern exists in the given path on the remote storage system
154+
*
155+
* @param string $path
156+
* @param string $pattern
157+
* @param string $message
158+
*
159+
* @throws \Magento\Framework\Exception\FileSystemException
160+
*/
161+
public function assertGlobbedFileExists($path, $pattern, $message = ""): void
162+
{
163+
$files = $this->driver->search($pattern, $path);
164+
$this->assertNotEmpty($files, $message);
165+
}
166+
152167
/**
153168
* Assert a file does not exist on the remote storage system
154169
*
@@ -206,6 +221,24 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
206221
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), $message);
207222
}
208223

224+
/**
225+
* Asserts that a file with the given glob pattern at the given path on the remote storage system contains a given string
226+
*
227+
* @param string $path
228+
* @param string $pattern
229+
* @param string $text
230+
* @param int $fileIndex
231+
* @param string $message
232+
* @return void
233+
*
234+
* @throws \Magento\Framework\Exception\FileSystemException
235+
*/
236+
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ""): void
237+
{
238+
$files = $this->driver->search($pattern, $path);
239+
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), $message);
240+
}
241+
209242
/**
210243
* Assert a file on the remote storage system does not contain a given string
211244
*

app/code/Magento/Catalog/Test/Mftf/Helper/LocalFileAssertions.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ public function assertFileExists($filePath, $message = ''): void
134134
$this->assertTrue($this->driver->isExists($realPath), $message);
135135
}
136136

137+
/**
138+
* Asserts that a file with the given glob pattern exists in the given path
139+
*
140+
* @param string $path
141+
* @param string $pattern
142+
* @param string $message
143+
*
144+
* @throws \Magento\Framework\Exception\FileSystemException
145+
*/
146+
public function assertGlobbedFileExists($path, $pattern, $message = ""): void
147+
{
148+
$realPath = $this->expandPath($path);
149+
$files = $this->driver->search($pattern, $realPath);
150+
$this->assertNotEmpty($files, $message);
151+
}
152+
137153
/**
138154
* Assert a file does not exist
139155
*
@@ -195,6 +211,25 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
195211
$this->assertStringContainsString($text, $this->driver->fileGetContents($realPath), $message);
196212
}
197213

214+
/**
215+
* Asserts that a file with the given glob pattern at the given path contains a given string
216+
*
217+
* @param string $path
218+
* @param string $pattern
219+
* @param string $text
220+
* @param int $fileIndex
221+
* @param string $message
222+
* @return void
223+
*
224+
* @throws \Magento\Framework\Exception\FileSystemException
225+
*/
226+
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ""): void
227+
{
228+
$realPath = $this->expandPath($path);
229+
$files = $this->driver->search($pattern, $realPath);
230+
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), $message);
231+
}
232+
198233
/**
199234
* Assert a file does not contain a given string
200235
*

0 commit comments

Comments
 (0)