[Miscellaneous] [Regex] Use simpler & stronger pattern to match name of file

This commit is contained in:
Meritoo
2019-12-18 20:25:06 +01:00
parent 872259e63d
commit ddb3f0a544
5 changed files with 16 additions and 9 deletions

View File

@@ -94,11 +94,14 @@ class MiscellaneousTest extends BaseTestCase
self::assertEquals($withoutExtension, Miscellaneous::getFileNameWithoutExtension($fileName));
}
public function testGetFileNameFromPath()
public function testGetFileNameFromPath(): void
{
// Path with file
self::assertEquals('sit.amet.JPG', Miscellaneous::getFileNameFromPath('lorem/ipsum-dolor/sit.amet.JPG'));
// Path with complicated name of file
self::assertEquals('this-1_2 3 & my! 4+file.jpg', Miscellaneous::getFileNameFromPath('lorem/ipsum-dolor/this-1_2 3 & my! 4+file.jpg'));
// Path without file
self::assertEquals('', Miscellaneous::getFileNameFromPath('lorem/ipsum-dolor/sit-amet'));