|
|
|
|
@ -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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|