Merge pull request #15744 from owncloud/fix-inverted-path-in-resourcenotfound

Fix wrong path generation
This commit is contained in:
Lukas Reschke 2015-04-20 16:55:36 +02:00
commit fe2cbc3795
2 changed files with 21 additions and 9 deletions

View File

@ -39,6 +39,6 @@ class ResourceNotFoundException extends \LogicException {
* @return string * @return string
*/ */
public function getResourcePath() { public function getResourcePath() {
return $this->resource . '/' . $this->webPath; return $this->webPath . '/' . $this->resource;
} }
} }

View File

@ -6,8 +6,12 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_ResourceLocator extends \Test\TestCase { namespace Test\Template;
/** @var PHPUnit_Framework_MockObject_MockObject */
use OC\Template\ResourceNotFoundException;
class ResourceLocator extends \Test\TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject */
protected $logger; protected $logger;
protected function setUp() { protected function setUp() {
@ -17,10 +21,14 @@ class Test_ResourceLocator extends \Test\TestCase {
/** /**
* @param string $theme * @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, $core_map, $party_map, $appsRoots) {
return $this->getMockForAbstractClass('OC\Template\ResourceLocator', return $this->getMockForAbstractClass('OC\Template\ResourceLocator',
array($this->logger, $theme, $core_map, $party_map, $appsroots ), array($this->logger, $theme, $core_map, $party_map, $appsRoots ),
'', true, true, true, array()); '', true, true, true, array());
} }
@ -44,6 +52,7 @@ class Test_ResourceLocator extends \Test\TestCase {
$locator->expects($this->once()) $locator->expects($this->once())
->method('doFindTheme') ->method('doFindTheme')
->with('foo'); ->with('foo');
/** @var \OC\Template\ResourceLocator $locator */
$locator->find(array('foo')); $locator->find(array('foo'));
} }
@ -53,20 +62,23 @@ class Test_ResourceLocator extends \Test\TestCase {
$locator->expects($this->once()) $locator->expects($this->once())
->method('doFind') ->method('doFind')
->with('foo') ->with('foo')
->will($this->throwException(new \OC\Template\ResourceNotFoundException('foo', 'map'))); ->will($this->throwException(new ResourceNotFoundException('foo', 'map')));
$locator->expects($this->once()) $locator->expects($this->once())
->method('doFindTheme') ->method('doFindTheme')
->with('foo') ->with('foo')
->will($this->throwException(new \OC\Template\ResourceNotFoundException('foo', 'map'))); ->will($this->throwException(new ResourceNotFoundException('foo', 'map')));
$this->logger->expects($this->exactly(2)) $this->logger->expects($this->exactly(2))
->method('error'); ->method('error')
->with($this->stringContains('map/foo'));
/** @var \OC\Template\ResourceLocator $locator */
$locator->find(array('foo')); $locator->find(array('foo'));
} }
public function testAppendIfExist() { public function testAppendIfExist() {
$locator = $this->getResourceLocator('theme', $locator = $this->getResourceLocator('theme',
array(__DIR__=>'map'), array('3rd'=>'party'), array('foo'=>'bar')); array(__DIR__=>'map'), array('3rd'=>'party'), array('foo'=>'bar'));
$method = new ReflectionMethod($locator, 'appendIfExist'); /** @var \OC\Template\ResourceLocator $locator */
$method = new \ReflectionMethod($locator, 'appendIfExist');
$method->setAccessible(true); $method->setAccessible(true);
$method->invoke($locator, __DIR__, basename(__FILE__), 'webroot'); $method->invoke($locator, __DIR__, basename(__FILE__), 'webroot');