diff --git a/modules/system/classes/FileManifest.php b/modules/system/classes/FileManifest.php index 5a0522b3c5..d03e5cd038 100644 --- a/modules/system/classes/FileManifest.php +++ b/modules/system/classes/FileManifest.php @@ -166,7 +166,7 @@ protected function findFiles(string $basePath): array */ protected function getFilename(string $file): string { - return str_replace($this->root, '', $file); + return substr($file, strlen($this->root)); } /** diff --git a/modules/system/tests/classes/FileManifestTest.php b/modules/system/tests/classes/FileManifestTest.php index 4cf280f07a..2ceb55301c 100644 --- a/modules/system/tests/classes/FileManifestTest.php +++ b/modules/system/tests/classes/FileManifestTest.php @@ -2,6 +2,8 @@ namespace System\Tests\Classes; +use ReflectionClass; + use System\Tests\Bootstrap\TestCase; use Winter\Storm\Exception\ApplicationException; use System\Classes\FileManifest; @@ -11,14 +13,15 @@ class FileManifestTest extends TestCase /** @var FileManifest instance */ protected $fileManifest; + /** @var root path */ + protected $root; + public function setUp(): void { parent::setUp(); - $this->fileManifest = new FileManifest( - base_path('modules/system/tests/fixtures/manifest/1_0_1'), - ['test', 'test2'] - ); + $this->root = base_path('modules/system/tests/fixtures/manifest/1_0_1'); + $this->fileManifest = new FileManifest($this->root, ['test', 'test2']); } public function testGetFiles() @@ -61,4 +64,15 @@ public function testSingleModule() 'test' => 'c0b794ff210862a4ce16223802efe6e28969f5a4fb42480ec8c2fef2da23d181', ], $this->fileManifest->getModuleChecksums()); } + + public function testGetFilename() + { + $class = new ReflectionClass('System\Classes\FileManifest'); + $method = $class->getMethod('getFilename'); + $method->setAccessible(true); + + $filename = '/modules/test/file1.php'; + + $this->assertEquals($filename, $method->invoke($this->fileManifest, $this->root . $filename)); + } }