Drop 3rdparty root since it is unused and adjust tests

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2022-12-07 23:16:06 +01:00
parent f0a0bfaaee
commit 4bcaeb6c2c
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF
5 changed files with 20 additions and 26 deletions

View file

@ -44,8 +44,7 @@ class CSSResourceLocator extends ResourceLocator {
public function doFind($style) {
$app = substr($style, 0, strpos($style, '/'));
if (strpos($style, '3rdparty') === 0
&& $this->appendIfExist($this->thirdpartyroot, $style.'.css')
|| $this->appendIfExist($this->serverroot, $style.'.css')
&& $this->appendIfExist($this->serverroot, $style.'.css')
|| $this->appendIfExist($this->serverroot, 'core/'.$style.'.css')
) {
return;

View file

@ -45,10 +45,6 @@ class JSResourceLocator extends ResourceLocator {
*/
public function doFind($script) {
$theme_dir = 'themes/'.$this->theme.'/';
if (strpos($script, '3rdparty') === 0
&& $this->appendIfExist($this->thirdpartyroot, $script.'.js')) {
return;
}
// Extracting the appId and the script file name
$app = substr($script, 0, strpos($script, '/'));

View file

@ -36,7 +36,6 @@ abstract class ResourceLocator {
protected $mapping;
protected $serverroot;
protected $thirdpartyroot;
protected $webroot;
protected $resources = [];
@ -49,8 +48,7 @@ abstract class ResourceLocator {
\OC::$SERVERROOT => \OC::$WEBROOT
];
$this->serverroot = \OC::$SERVERROOT;
$this->thirdpartyroot = \OC::$SERVERROOT;
$this->webroot = $this->mapping[$this->serverroot];
$this->webroot = \OC::$WEBROOT;
$this->theme = \OC_Util::getTheme();
}

View file

@ -63,9 +63,6 @@ class JSResourceLocatorTest extends \Test\TestCase {
);
return new JSResourceLocator(
$this->logger,
'theme',
['core' => 'map'],
['3rd' => 'party'],
$jsCombiner
);
}

View file

@ -8,6 +8,7 @@
namespace Test\Template;
use OC\SystemConfig;
use OC\Template\ResourceNotFoundException;
use Psr\Log\LoggerInterface;
@ -22,20 +23,23 @@ class ResourceLocatorTest extends \Test\TestCase {
/**
* @param string $theme
* @param array $core_map
* @param array $party_map
* @param array $appsRoots
* @return \PHPUnit\Framework\MockObject\MockObject
*/
public function getResourceLocator($theme, $core_map, $party_map, $appsRoots) {
public function getResourceLocator($theme) {
$systemConfig = $this->createMock(SystemConfig::class);
$systemConfig
->expects($this->any())
->method('getValue')
->with('theme', '')
->willReturn($theme);
$this->overwriteService(SystemConfig::class, $systemConfig);
return $this->getMockForAbstractClass('OC\Template\ResourceLocator',
[$this->logger, $theme, $core_map, $party_map, $appsRoots ],
[$this->logger],
'', true, true, true, []);
}
public function testFind() {
$locator = $this->getResourceLocator('theme',
['core' => 'map'], ['3rd' => 'party'], ['foo' => 'bar']);
$locator = $this->getResourceLocator('theme');
$locator->expects($this->once())
->method('doFind')
->with('foo');
@ -47,6 +51,11 @@ class ResourceLocatorTest extends \Test\TestCase {
}
public function testFindNotFound() {
$systemConfig = $this->createMock(SystemConfig::class);
$systemConfig->method('getValue')
->with('theme', '')
->willReturn('theme');
$this->overwriteService(SystemConfig::class, $systemConfig);
$locator = $this->getResourceLocator('theme',
['core' => 'map'], ['3rd' => 'party'], ['foo' => 'bar']);
$locator->expects($this->once())
@ -65,8 +74,7 @@ class ResourceLocatorTest extends \Test\TestCase {
}
public function testAppendIfExist() {
$locator = $this->getResourceLocator('theme',
[__DIR__ => 'map'], ['3rd' => 'party'], ['foo' => 'bar']);
$locator = $this->getResourceLocator('theme');
/** @var \OC\Template\ResourceLocator $locator */
$method = new \ReflectionMethod($locator, 'appendIfExist');
$method->setAccessible(true);
@ -75,11 +83,7 @@ class ResourceLocatorTest extends \Test\TestCase {
$resource1 = [__DIR__, 'webroot', basename(__FILE__)];
$this->assertEquals([$resource1], $locator->getResources());
$method->invoke($locator, __DIR__, basename(__FILE__));
$resource2 = [__DIR__, 'map', basename(__FILE__)];
$this->assertEquals([$resource1, $resource2], $locator->getResources());
$method->invoke($locator, __DIR__, 'does-not-exist');
$this->assertEquals([$resource1, $resource2], $locator->getResources());
$this->assertEquals([$resource1], $locator->getResources());
}
}