mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Root-level module support in Module->getResourcePath()
See https://github.com/silverstripe/silverstripe-framework/pull/6733
This commit is contained in:
parent
59ee2c1037
commit
ac9d645e4e
@ -162,9 +162,9 @@ class Module implements Serializable
|
||||
*/
|
||||
public function getResourcePath($path)
|
||||
{
|
||||
$base = rtrim($this->getRelativePath(), '/\\');
|
||||
$path = rtrim($path, '/\\');
|
||||
return "{$base}/{$path}";
|
||||
$base = trim($this->getRelativePath(), '/\\');
|
||||
$path = trim($path, '/\\');
|
||||
return trim("{$base}/{$path}", '/\\');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,7 @@ class ModuleManifestTest extends SapphireTest
|
||||
$modules = $this->manifest->getModules();
|
||||
$this->assertEquals(
|
||||
[
|
||||
'silverstripe/root-module',
|
||||
'module',
|
||||
'silverstripe/awesome-module',
|
||||
],
|
||||
@ -74,7 +75,7 @@ class ModuleManifestTest extends SapphireTest
|
||||
* Note: Tests experimental API
|
||||
* @internal
|
||||
*/
|
||||
public function testGetResource()
|
||||
public function testGetResourcePath()
|
||||
{
|
||||
$module = $this->manifest->getModule('moduleb');
|
||||
$this->assertTrue($module->hasResource('composer.json'));
|
||||
@ -84,4 +85,18 @@ class ModuleManifestTest extends SapphireTest
|
||||
$module->getResourcePath('composer.json')
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: Tests experimental API
|
||||
* @internal
|
||||
*/
|
||||
public function testGetResourcePathOnRoot()
|
||||
{
|
||||
$module = $this->manifest->getModule('silverstripe/root-module');
|
||||
$this->assertTrue($module->hasResource('composer.json'));
|
||||
$this->assertEquals(
|
||||
'composer.json',
|
||||
$module->getResourcePath('composer.json')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<?php
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "silverstripe/root-module",
|
||||
"description": "dummy test module",
|
||||
"require": {},
|
||||
"extra": {
|
||||
"installer-name": "root-module"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user