Skip to content

Commit d8e8233

Browse files
#24431: Added unit test.
1 parent 6b8c7ee commit d8e8233

File tree

1 file changed

+31
-0
lines changed
  • app/code/Magento/Theme/Test/Unit/Model/Design/Backend

1 file changed

+31
-0
lines changed

app/code/Magento/Theme/Test/Unit/Model/Design/Backend/FileTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,35 @@ public function testBeforeSaveWithExistingFile()
282282
$this->fileBackend->getValue()
283283
);
284284
}
285+
286+
/**
287+
* Test for getRelativeMediaPath method.
288+
*
289+
* @param string $path
290+
* @param string $filename
291+
* @dataProvider getRelativeMediaPathDataProvider
292+
*/
293+
public function testGetRelativeMediaPath(string $path, string $filename)
294+
{
295+
$reflection = new \ReflectionClass($this->fileBackend);
296+
$method = $reflection->getMethod('getRelativeMediaPath');
297+
$method->setAccessible(true);
298+
$this->assertEquals(
299+
$filename,
300+
$method->invoke($this->fileBackend, $path . $filename)
301+
);
302+
}
303+
304+
/**
305+
* Data provider for testGetRelativeMediaPath.
306+
*
307+
* @return array
308+
*/
309+
public function getRelativeMediaPathDataProvider(): array
310+
{
311+
return [
312+
'Normal path' => ['pub/media/', 'filename.jpg'],
313+
'Complex path' => ['somepath/pub/media/', 'filename.jpg'],
314+
];
315+
}
285316
}

0 commit comments

Comments
 (0)