mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #6750 from open-sausages/pulls/4.0/fix-module-resource-trim
Root-level module support in Module->getResourcePath()
This commit is contained in:
commit
1aa2677353
@ -162,9 +162,9 @@ class Module implements Serializable
|
|||||||
*/
|
*/
|
||||||
public function getResourcePath($path)
|
public function getResourcePath($path)
|
||||||
{
|
{
|
||||||
$base = rtrim($this->getRelativePath(), '/\\');
|
$base = trim($this->getRelativePath(), '/\\');
|
||||||
$path = rtrim($path, '/\\');
|
$path = trim($path, '/\\');
|
||||||
return "{$base}/{$path}";
|
return trim("{$base}/{$path}", '/\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +31,7 @@ class ModuleManifestTest extends SapphireTest
|
|||||||
$modules = $this->manifest->getModules();
|
$modules = $this->manifest->getModules();
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
[
|
[
|
||||||
|
'silverstripe/root-module',
|
||||||
'module',
|
'module',
|
||||||
'silverstripe/awesome-module',
|
'silverstripe/awesome-module',
|
||||||
],
|
],
|
||||||
@ -74,7 +75,7 @@ class ModuleManifestTest extends SapphireTest
|
|||||||
* Note: Tests experimental API
|
* Note: Tests experimental API
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function testGetResource()
|
public function testGetResourcePath()
|
||||||
{
|
{
|
||||||
$module = $this->manifest->getModule('moduleb');
|
$module = $this->manifest->getModule('moduleb');
|
||||||
$this->assertTrue($module->hasResource('composer.json'));
|
$this->assertTrue($module->hasResource('composer.json'));
|
||||||
@ -84,4 +85,18 @@ class ModuleManifestTest extends SapphireTest
|
|||||||
$module->getResourcePath('composer.json')
|
$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…
x
Reference in New Issue
Block a user