summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-03-17 12:35:47 +0100
committerLukas Reschke <lukas@owncloud.com>2015-03-17 12:35:47 +0100
commit9e2ebf2dcea8d3e1ee153eba43124ca95c496443 (patch)
treed48d32dcd87aa77304c7dd9f0acc6d79fd2993fd /tests
parentd96b97043b2fa7ba4d676c1d7b44f4aa5e58c8ee (diff)
downloadnextcloud-server-9e2ebf2dcea8d3e1ee153eba43124ca95c496443.tar.gz
nextcloud-server-9e2ebf2dcea8d3e1ee153eba43124ca95c496443.zip
Cache \OC\URLGenerator::imagePath
\OC\URLGenerator::imagePath is a really expensive operation due to all the I/O handling and can really benefit from caching.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/urlgenerator.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/lib/urlgenerator.php b/tests/lib/urlgenerator.php
index a92aaddeb4c..60e1a86f16a 100644
--- a/tests/lib/urlgenerator.php
+++ b/tests/lib/urlgenerator.php
@@ -16,7 +16,8 @@ class Test_Urlgenerator extends \Test\TestCase {
public function testLinkToDocRoot($app, $file, $args, $expectedResult) {
\OC::$WEBROOT = '';
$config = $this->getMock('\OCP\IConfig');
- $urlGenerator = new \OC\URLGenerator($config);
+ $cacheFactory = $this->getMock('\OCP\ICacheFactory');
+ $urlGenerator = new \OC\URLGenerator($config, $cacheFactory);
$result = $urlGenerator->linkTo($app, $file, $args);
$this->assertEquals($expectedResult, $result);
@@ -30,7 +31,8 @@ class Test_Urlgenerator extends \Test\TestCase {
public function testLinkToSubDir($app, $file, $args, $expectedResult) {
\OC::$WEBROOT = '/owncloud';
$config = $this->getMock('\OCP\IConfig');
- $urlGenerator = new \OC\URLGenerator($config);
+ $cacheFactory = $this->getMock('\OCP\ICacheFactory');
+ $urlGenerator = new \OC\URLGenerator($config, $cacheFactory);
$result = $urlGenerator->linkTo($app, $file, $args);
$this->assertEquals($expectedResult, $result);
@@ -42,7 +44,8 @@ class Test_Urlgenerator extends \Test\TestCase {
public function testLinkToRouteAbsolute($route, $expected) {
\OC::$WEBROOT = '/owncloud';
$config = $this->getMock('\OCP\IConfig');
- $urlGenerator = new \OC\URLGenerator($config);
+ $cacheFactory = $this->getMock('\OCP\ICacheFactory');
+ $urlGenerator = new \OC\URLGenerator($config, $cacheFactory);
$result = $urlGenerator->linkToRouteAbsolute($route);
$this->assertEquals($expected, $result);
@@ -79,7 +82,9 @@ class Test_Urlgenerator extends \Test\TestCase {
function testGetAbsoluteURLDocRoot($url, $expectedResult) {
\OC::$WEBROOT = '';
- $urlGenerator = new \OC\URLGenerator(null);
+ $config = $this->getMock('\OCP\IConfig');
+ $cacheFactory = $this->getMock('\OCP\ICacheFactory');
+ $urlGenerator = new \OC\URLGenerator($config, $cacheFactory);
$result = $urlGenerator->getAbsoluteURL($url);
$this->assertEquals($expectedResult, $result);
@@ -93,7 +98,9 @@ class Test_Urlgenerator extends \Test\TestCase {
function testGetAbsoluteURLSubDir($url, $expectedResult) {
\OC::$WEBROOT = '/owncloud';
- $urlGenerator = new \OC\URLGenerator(null);
+ $config = $this->getMock('\OCP\IConfig');
+ $cacheFactory = $this->getMock('\OCP\ICacheFactory');
+ $urlGenerator = new \OC\URLGenerator($config, $cacheFactory);
$result = $urlGenerator->getAbsoluteURL($url);
$this->assertEquals($expectedResult, $result);