diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-03-09 23:33:25 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-03-09 23:33:25 +0100 |
commit | c8ed88f4d66167dda13da279239791327cee9310 (patch) | |
tree | 963569217f78f1002094fba64e86c6897b3ca9cc /tests | |
parent | 2f6188495651cc78e7161e3af8b8b1f3a38f058a (diff) | |
parent | 716ba49a82ab7c0a68f3b4f442ea8ed84c06f317 (diff) | |
download | nextcloud-server-c8ed88f4d66167dda13da279239791327cee9310.tar.gz nextcloud-server-c8ed88f4d66167dda13da279239791327cee9310.zip |
Merge pull request #14689 from owncloud/better-missing-resource-handling
Log errors and create 404 in network list when a css or js is missing
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/template/resourcelocator.php | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/tests/lib/template/resourcelocator.php b/tests/lib/template/resourcelocator.php index f350fd144e1..b0851621fd2 100644 --- a/tests/lib/template/resourcelocator.php +++ b/tests/lib/template/resourcelocator.php @@ -7,13 +7,20 @@ */ class Test_ResourceLocator extends \Test\TestCase { + /** @var PHPUnit_Framework_MockObject_MockObject */ + protected $logger; + + protected function setUp() { + parent::setUp(); + $this->logger = $this->getMock('OCP\ILogger'); + } /** * @param string $theme */ public function getResourceLocator( $theme, $core_map, $party_map, $appsroots ) { return $this->getMockForAbstractClass('OC\Template\ResourceLocator', - array( $theme, $core_map, $party_map, $appsroots ), + array($this->logger, $theme, $core_map, $party_map, $appsroots ), '', true, true, true, array()); } @@ -30,7 +37,7 @@ class Test_ResourceLocator extends \Test\TestCase { public function testFind() { $locator = $this->getResourceLocator('theme', - array('core'=>'map'), array('3rd'=>'party'), array('foo'=>'bar')); + array('core' => 'map'), array('3rd' => 'party'), array('foo' => 'bar')); $locator->expects($this->once()) ->method('doFind') ->with('foo'); @@ -38,18 +45,22 @@ class Test_ResourceLocator extends \Test\TestCase { ->method('doFindTheme') ->with('foo'); $locator->find(array('foo')); + } + public function testFindNotFound() { $locator = $this->getResourceLocator('theme', array('core'=>'map'), array('3rd'=>'party'), array('foo'=>'bar')); $locator->expects($this->once()) ->method('doFind') ->with('foo') - ->will($this->throwException(new Exception('test'))); - try { - $locator->find(array('foo')); - } catch (\Exception $e) { - $this->assertEquals('test serverroot:core', $e->getMessage()); - } + ->will($this->throwException(new \OC\Template\ResourceNotFoundException('foo', 'map'))); + $locator->expects($this->once()) + ->method('doFindTheme') + ->with('foo') + ->will($this->throwException(new \OC\Template\ResourceNotFoundException('foo', 'map'))); + $this->logger->expects($this->exactly(2)) + ->method('error'); + $locator->find(array('foo')); } public function testAppendIfExist() { |