summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-04-15 20:03:00 +0200
committerRobin Appelman <icewind@owncloud.com>2014-04-15 20:03:00 +0200
commitc82adb8c5db01d6a49c4364f7eecb2931f59cfa1 (patch)
tree2c18fa58b47ff03aa3f872a1c13c0b2fe4968fed /tests
parent371a924c92bb751b81e2a819d8c581743be7a797 (diff)
parent2eeab60378a3e22e19c4f435aa2bf65cc9da7c2a (diff)
downloadnextcloud-server-c82adb8c5db01d6a49c4364f7eecb2931f59cfa1.tar.gz
nextcloud-server-c82adb8c5db01d6a49c4364f7eecb2931f59cfa1.zip
merge master into webdav-injection
Diffstat (limited to 'tests')
-rw-r--r--tests/bootstrap.php1
-rw-r--r--tests/data/lorem-big.txt29
-rw-r--r--tests/karma.config.js10
-rw-r--r--tests/lib/api.php2
-rw-r--r--tests/lib/appframework/dependencyinjection/DIContainerTest.php2
-rw-r--r--tests/lib/appframework/http/JSONResponseTest.php10
-rw-r--r--tests/lib/appframework/http/RequestTest.php28
-rw-r--r--tests/lib/appframework/http/ResponseTest.php20
-rw-r--r--tests/lib/appframework/http/TemplateResponseTest.php10
-rw-r--r--tests/lib/appframework/middleware/MiddlewareDispatcherTest.php2
-rw-r--r--tests/lib/appframework/routing/RoutingTest.php32
-rw-r--r--tests/lib/dbschema.php3
-rw-r--r--tests/lib/files/filesystem.php51
-rw-r--r--tests/lib/files/storage/storage.php81
-rw-r--r--tests/lib/group/group.php62
-rw-r--r--tests/lib/mail.php9
-rw-r--r--tests/lib/preview.php140
-rw-r--r--tests/lib/public/ocpconfig.php37
-rw-r--r--tests/lib/share/share.php12
-rw-r--r--tests/lib/urlgenerator.php30
20 files changed, 480 insertions, 91 deletions
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 70de7cd1c44..99374d68a5c 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -16,3 +16,4 @@ if (!class_exists('PHPUnit_Framework_TestCase')) {
OC_Hook::clear();
OC_Log::$enabled = false;
+OC_FileProxy::clearProxies();
diff --git a/tests/data/lorem-big.txt b/tests/data/lorem-big.txt
new file mode 100644
index 00000000000..3712b9d30f0
--- /dev/null
+++ b/tests/data/lorem-big.txt
@@ -0,0 +1,29 @@
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id hendrerit felis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed dictum dolor nec lobortis sagittis. Aliquam blandit lobortis ullamcorper. Donec malesuada ante ante, vel cursus purus suscipit ut. Sed a eros vitae lorem tristique hendrerit a a odio. Cras interdum mi lectus, sed molestie mauris tempus sit amet. Praesent auctor neque venenatis diam tincidunt sodales. Maecenas tincidunt ligula et ipsum dignissim, et molestie dui hendrerit. Nunc lobortis mauris vel tempor tristique. Sed consectetur bibendum nunc. Pellentesque augue velit, interdum ac posuere eu, eleifend et massa. Vestibulum ac mi eu mi viverra iaculis. Sed consequat leo adipiscing dui varius, sagittis vestibulum massa vehicula.
+
+Praesent imperdiet erat vitae dui placerat, sit amet vulputate tortor viverra. In laoreet elit lorem, at luctus est tempor ac. Nam elementum scelerisque nisl vitae accumsan. Curabitur cursus rutrum est, ut adipiscing ante elementum ut. Ut lectus sem, luctus ut massa non, dignissim vestibulum ipsum. Suspendisse non convallis enim, aliquam adipiscing velit. Donec pharetra non turpis hendrerit porttitor. Aliquam erat volutpat.
+
+Cras eget arcu eu dolor faucibus accumsan non eget orci. Integer quis quam tincidunt, faucibus neque in, imperdiet lacus. Aenean dui turpis, lacinia quis ligula non, semper adipiscing tellus. Curabitur vitae dui quis nisl malesuada commodo. Nunc eleifend metus enim, eu aliquet dui semper sit amet. Sed a odio sapien. Suspendisse vitae ante id sapien semper accumsan. Sed vestibulum erat quis laoreet pellentesque. Nullam placerat ligula eu odio faucibus, eget dictum orci tristique. Quisque sit amet pulvinar velit, lacinia dictum sem.
+
+Phasellus id sagittis lacus. Vivamus facilisis convallis metus, sit amet ultricies purus gravida quis. Vivamus eget egestas arcu, a euismod risus. Fusce metus arcu, molestie ut lacinia at, commodo eu nibh. In leo tortor, feugiat aliquet semper in, malesuada ac nulla. Fusce tempor ultricies blandit. Pellentesque et lorem quam. Suspendisse eros eros, mattis ut porttitor vitae, fermentum eget augue. Aliquam vitae justo sed est dictum lobortis. Cras lacinia commodo ligula sed ornare. Donec ut eros semper, sodales tellus quis, cursus quam. Quisque elementum ullamcorper pellentesque. Integer in rutrum ante, vel condimentum metus. Aliquam erat volutpat.
+
+Quisque convallis tempus eros, sit amet mattis ipsum eleifend in. Mauris volutpat, urna ut commodo tempus, est quam scelerisque erat, eget consequat nulla arcu id eros. Nam elementum nibh quis tincidunt adipiscing. Fusce tristique pretium mollis. Nulla quis ornare felis, vel lacinia diam. In et dui et mauris vestibulum commodo. In hac habitasse platea dictumst. Vestibulum viverra pellentesque tortor, tempor vehicula orci. Praesent rutrum turpis ipsum, ac commodo nisi vehicula ac.
+
+Nulla gravida ultrices mauris. Ut congue purus nec dolor euismod, vitae auctor elit condimentum. Nullam elementum velit lectus, fringilla pharetra sem hendrerit sit amet. Cras quis lobortis nisi, id interdum massa. Proin eget porttitor sapien. Vivamus quam odio, consectetur at rhoncus vel, posuere in nisi. Donec hendrerit urna ac massa tristique, pellentesque consequat orci dapibus. Mauris mi erat, aliquet id adipiscing ultricies, ultrices nec lacus. Proin imperdiet elit magna, ut suscipit metus faucibus eget. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas at leo lorem. Donec mi nibh, blandit ut mi quis, dictum adipiscing ante. Curabitur sodales blandit odio id viverra. Fusce sagittis rutrum nibh. Mauris risus lacus, placerat at dictum in, varius volutpat quam.
+
+Ut accumsan tincidunt dui, non semper lorem sodales nec. Curabitur pellentesque velit nec erat ultrices, in convallis diam suscipit. Curabitur pellentesque convallis mi. Phasellus iaculis orci quis nisi semper auctor. Vestibulum eleifend tortor quis odio feugiat, pulvinar congue turpis blandit. Sed viverra diam risus, vel mattis orci dignissim ut. Cras pellentesque dapibus dolor. Morbi tempor eleifend magna. Ut sodales ut sapien sed elementum. In hac habitasse platea dictumst.
+
+Nullam eget sagittis tellus. Donec a tellus id ligula viverra pellentesque. Pellentesque nulla turpis, pretium vel sem vel, placerat ultricies diam. Donec felis nibh, rhoncus id ornare at, lobortis vel massa. Nullam eu luctus ipsum. Mauris consequat dictum aliquam. Suspendisse ullamcorper aliquam mauris, viverra tincidunt augue suscipit at. Sed luctus scelerisque justo ut semper. Phasellus massa mauris, molestie at nulla eget, dictum ultricies nisi. Aliquam rhoncus nisl sed urna egestas, vel luctus lectus euismod. Mauris sagittis dapibus leo. Donec vitae dignissim risus, ac ultricies augue. Ut vulputate tortor sed dui consectetur placerat. Nullam viverra non diam vel dignissim.
+
+Suspendisse potenti. Integer facilisis neque vitae euismod adipiscing. Aenean dictum leo commodo dui sodales, sit amet volutpat mauris gravida. Proin tempus convallis eros at consectetur. Proin nisl purus, dictum vel euismod ut, imperdiet quis est. Etiam sollicitudin lobortis neque eget pulvinar. Etiam venenatis vel sem ut posuere. Aliquam consectetur rhoncus facilisis. Morbi a viverra orci.
+
+Praesent ut vehicula orci, vel convallis risus. Suspendisse consectetur varius interdum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Proin vel sodales enim. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur suscipit tristique justo vel dapibus. Sed tincidunt mattis massa a auctor. Donec in tincidunt elit. Curabitur interdum neque at ante fringilla tempus. In hac habitasse platea dictumst. Vivamus luctus ligula ut nisl fermentum egestas. Praesent pulvinar accumsan neque. Sed nec leo sit amet arcu vehicula vehicula non ac diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
+
+Morbi vel arcu quis neque dictum ullamcorper. Pellentesque condimentum consequat lacinia. Vestibulum eleifend placerat erat, eu hendrerit dui pulvinar eget. Vestibulum accumsan, lectus id vehicula fringilla, erat eros dictum massa, ut tristique libero mi eu ante. In at ante nunc. Praesent sodales ullamcorper porta. Curabitur egestas odio elit. Praesent et libero malesuada, venenatis lorem vitae, eleifend nisl. Donec dapibus euismod turpis, nec porttitor turpis dapibus ac. Fusce iaculis lacus eget dictum aliquam. Sed dictum eu enim ac posuere. Ut accumsan, ipsum et laoreet consectetur, ipsum quam dapibus diam, ac molestie ligula dui id massa. Nulla aliquam mauris congue nibh vestibulum imperdiet.
+
+Aenean ultricies, orci vel consectetur suscipit, ante nisi eleifend est, vitae suscipit risus erat dictum dui. Ut nisi diam, tristique sed nisl nec, aliquam gravida orci. Vestibulum in molestie sem. Ut eu molestie mi. Suspendisse potenti. Nunc sagittis lorem ut est vehicula, vitae imperdiet leo rutrum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec pharetra urna pretium, faucibus orci cursus, sodales purus. Duis iaculis dignissim augue, non aliquet ligula elementum quis. Sed tempus a nisi et faucibus. Donec mattis ligula ac sem aliquam, sed sodales est ullamcorper. Cras vel orci est. Integer eget ultricies nisi.
+
+Quisque rhoncus, nisl vel auctor consectetur, sapien augue iaculis urna, quis suscipit arcu dolor ac est. Fusce sit amet quam lacinia, malesuada lorem vitae, dapibus justo. Mauris eget massa nec dolor volutpat tempor ut eu ante. Donec risus mi, aliquam at euismod vulputate, ullamcorper non leo. Etiam ac elit velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus sollicitudin enim sed felis pharetra, a convallis mi venenatis. Donec convallis non velit venenatis suscipit. Sed massa risus, dictum quis aliquam ut, placerat quis arcu. Donec at nisi neque. Nullam porta et mi vel ultricies. Donec vel aliquam sem. Mauris varius, ipsum interdum mattis rhoncus, nunc nisl vehicula tortor, quis condimentum nibh nisl vel ante. Sed vel pretium dui. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce pulvinar molestie neque, quis luctus ante.
+
+Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec ac ipsum egestas, luctus urna aliquet, fringilla tortor. Cras eleifend sed tellus tempor congue. Integer venenatis magna dignissim pharetra cursus. Nulla volutpat, sem sit amet malesuada laoreet, odio libero consectetur orci, sit amet pellentesque neque ligula quis libero. Morbi nec interdum metus, in imperdiet justo. Fusce euismod egestas nulla et elementum. Etiam aliquam lectus quis eros semper, sed dapibus velit ultrices. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+
+Proin sed elit vel massa placerat mattis et vel mauris. Aliquam accumsan ante ligula, at accumsan enim pellentesque sit amet. Sed eget quam vel nunc molestie iaculis vitae nec massa. Vivamus sed accumsan libero. Duis pretium quam at blandit sollicitudin. Nullam sodales sit amet elit ac adipiscing. Ut ullamcorper dignissim sapien. Nulla facilisi. Fusce sed consequat lectus, et tempus ipsum. Aliquam vestibulum lectus vitae quam mollis, et adipiscing nisl lobortis
diff --git a/tests/karma.config.js b/tests/karma.config.js
index 529bd31338f..338e3f868e9 100644
--- a/tests/karma.config.js
+++ b/tests/karma.config.js
@@ -121,6 +121,9 @@ module.exports = function(config) {
files.push('apps/' + appsToTest[i] + '/tests/js/*.js');
}
+ // serve images to avoid warnings
+ files.push({pattern: 'core/img/**/*', watched: false, included: false, served: true});
+
config.set({
// base path, that will be used to resolve files and exclude
@@ -137,6 +140,11 @@ module.exports = function(config) {
],
+ proxies: {
+ // prevent warnings for images
+ '/context.html//core/img/': 'http://localhost:9876/base/core/img/'
+ },
+
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['dots', 'junit', 'coverage'],
@@ -167,7 +175,7 @@ module.exports = function(config) {
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
- autoWatch: false,
+ autoWatch: true,
// Start these browsers, currently available:
// - Chrome
diff --git a/tests/lib/api.php b/tests/lib/api.php
index 233beebd68a..0f7d08543ea 100644
--- a/tests/lib/api.php
+++ b/tests/lib/api.php
@@ -37,7 +37,7 @@ class Test_API extends PHPUnit_Framework_TestCase {
function dataProviderTestOneResult() {
return array(
array(100, true),
- array(101, true),
+ array(101, false),
array(997, false),
);
}
diff --git a/tests/lib/appframework/dependencyinjection/DIContainerTest.php b/tests/lib/appframework/dependencyinjection/DIContainerTest.php
index f3ebff0207f..d1bc900fb28 100644
--- a/tests/lib/appframework/dependencyinjection/DIContainerTest.php
+++ b/tests/lib/appframework/dependencyinjection/DIContainerTest.php
@@ -70,7 +70,7 @@ class DIContainerTest extends \PHPUnit_Framework_TestCase {
public function testMiddlewareDispatcherIncludesSecurityMiddleware(){
- $this->container['Request'] = new Request();
+ $this->container['Request'] = new Request(array('method' => 'GET'));
$security = $this->container['SecurityMiddleware'];
$dispatcher = $this->container['MiddlewareDispatcher'];
diff --git a/tests/lib/appframework/http/JSONResponseTest.php b/tests/lib/appframework/http/JSONResponseTest.php
index 534c54cbcee..b9b7c7d6382 100644
--- a/tests/lib/appframework/http/JSONResponseTest.php
+++ b/tests/lib/appframework/http/JSONResponseTest.php
@@ -28,6 +28,7 @@ namespace OC\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\AppFramework\Http;
//require_once(__DIR__ . "/../classloader.php");
@@ -95,4 +96,13 @@ class JSONResponseTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($code, $response->getStatus());
}
+ public function testChainability() {
+ $params = array('hi', 'yo');
+ $this->json->setData($params)
+ ->setStatus(Http::STATUS_NOT_FOUND);
+
+ $this->assertEquals(Http::STATUS_NOT_FOUND, $this->json->getStatus());
+ $this->assertEquals(array('hi', 'yo'), $this->json->getData());
+ }
+
}
diff --git a/tests/lib/appframework/http/RequestTest.php b/tests/lib/appframework/http/RequestTest.php
index 00473a8c44f..58828d17bb2 100644
--- a/tests/lib/appframework/http/RequestTest.php
+++ b/tests/lib/appframework/http/RequestTest.php
@@ -18,6 +18,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
stream_wrapper_unregister('fakeinput');
}
stream_wrapper_register('fakeinput', 'RequestStream');
+ $this->stream = 'fakeinput://data';
}
public function tearDown() {
@@ -30,7 +31,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
'method' => 'GET',
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
// Countable
$this->assertEquals(2, count($request));
@@ -54,9 +55,10 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
'post' => array('name' => 'Jane Doe', 'nickname' => 'Janey'),
'urlParams' => array('user' => 'jw', 'name' => 'Johnny Weissmüller'),
+ 'method' => 'GET'
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
$this->assertEquals(3, count($request));
$this->assertEquals('Janey', $request->{'nickname'});
@@ -70,9 +72,10 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
public function testImmutableArrayAccess() {
$vars = array(
'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
+ 'method' => 'GET'
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
$request['nickname'] = 'Janey';
}
@@ -82,9 +85,10 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
public function testImmutableMagicAccess() {
$vars = array(
'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
+ 'method' => 'GET'
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
$request->{'nickname'} = 'Janey';
}
@@ -97,7 +101,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
'method' => 'GET',
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
$result = $request->post;
}
@@ -107,7 +111,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
'method' => 'GET',
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
$this->assertEquals('GET', $request->method);
$result = $request->get;
$this->assertEquals('John Q. Public', $result['name']);
@@ -119,10 +123,10 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
$data = '{"name": "John Q. Public", "nickname": "Joey"}';
$vars = array(
'method' => 'POST',
- 'server' => array('CONTENT_TYPE' => 'application/json; utf-8'),
+ 'server' => array('CONTENT_TYPE' => 'application/json; utf-8')
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
$this->assertEquals('POST', $request->method);
$result = $request->post;
$this->assertEquals('John Q. Public', $result['name']);
@@ -140,7 +144,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
'server' => array('CONTENT_TYPE' => 'application/x-www-form-urlencoded'),
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
$this->assertEquals('PATCH', $request->method);
$result = $request->patch;
@@ -159,7 +163,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
'server' => array('CONTENT_TYPE' => 'application/json; utf-8'),
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
$this->assertEquals('PUT', $request->method);
$result = $request->put;
@@ -174,7 +178,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
'server' => array('CONTENT_TYPE' => 'application/json; utf-8'),
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
$this->assertEquals('PATCH', $request->method);
$result = $request->patch;
@@ -193,7 +197,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
'server' => array('CONTENT_TYPE' => 'image/png'),
);
- $request = new Request($vars);
+ $request = new Request($vars, $this->stream);
$this->assertEquals('PUT', $request->method);
$resource = $request->put;
$contents = stream_get_contents($resource);
diff --git a/tests/lib/appframework/http/ResponseTest.php b/tests/lib/appframework/http/ResponseTest.php
index 063ab8b5d33..27350725d79 100644
--- a/tests/lib/appframework/http/ResponseTest.php
+++ b/tests/lib/appframework/http/ResponseTest.php
@@ -117,5 +117,25 @@ class ResponseTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals('Thu, 01 Jan 1970 00:00:01 +0000', $headers['Last-Modified']);
}
+ public function testChainability() {
+ $lastModified = new \DateTime(null, new \DateTimeZone('GMT'));
+ $lastModified->setTimestamp(1);
+
+ $this->childResponse->setEtag('hi')
+ ->setStatus(Http::STATUS_NOT_FOUND)
+ ->setLastModified($lastModified)
+ ->cacheFor(33)
+ ->addHeader('hello', 'world');
+
+ $headers = $this->childResponse->getHeaders();
+
+ $this->assertEquals('world', $headers['hello']);
+ $this->assertEquals(Http::STATUS_NOT_FOUND, $this->childResponse->getStatus());
+ $this->assertEquals('hi', $this->childResponse->getEtag());
+ $this->assertEquals('Thu, 01 Jan 1970 00:00:01 +0000', $headers['Last-Modified']);
+ $this->assertEquals('max-age=33, must-revalidate',
+ $headers['Cache-Control']);
+
+ }
}
diff --git a/tests/lib/appframework/http/TemplateResponseTest.php b/tests/lib/appframework/http/TemplateResponseTest.php
index a583d9da14f..0b158edff6f 100644
--- a/tests/lib/appframework/http/TemplateResponseTest.php
+++ b/tests/lib/appframework/http/TemplateResponseTest.php
@@ -25,6 +25,7 @@
namespace OC\AppFramework\Http;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Http;
class TemplateResponseTest extends \PHPUnit_Framework_TestCase {
@@ -98,4 +99,13 @@ class TemplateResponseTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($render, $this->tpl->getRenderAs());
}
+ public function testChainability() {
+ $params = array('hi' => 'yo');
+ $this->tpl->setParams($params)
+ ->setStatus(Http::STATUS_NOT_FOUND);
+
+ $this->assertEquals(Http::STATUS_NOT_FOUND, $this->tpl->getStatus());
+ $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams());
+ }
+
}
diff --git a/tests/lib/appframework/middleware/MiddlewareDispatcherTest.php b/tests/lib/appframework/middleware/MiddlewareDispatcherTest.php
index f16b14150c3..935f97d2a6f 100644
--- a/tests/lib/appframework/middleware/MiddlewareDispatcherTest.php
+++ b/tests/lib/appframework/middleware/MiddlewareDispatcherTest.php
@@ -132,7 +132,7 @@ class MiddlewareDispatcherTest extends \PHPUnit_Framework_TestCase {
private function getControllerMock(){
return $this->getMock('OCP\AppFramework\Controller', array('method'),
- array($this->getAPIMock(), new Request()));
+ array($this->getAPIMock(), new Request(array('method' => 'GET'))));
}
diff --git a/tests/lib/appframework/routing/RoutingTest.php b/tests/lib/appframework/routing/RoutingTest.php
index 9f2675bf0b4..261ab0b26af 100644
--- a/tests/lib/appframework/routing/RoutingTest.php
+++ b/tests/lib/appframework/routing/RoutingTest.php
@@ -36,6 +36,16 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase
$this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open');
}
+ public function testSimpleRouteWithRequirements()
+ {
+ $routes = array('routes' => array(
+ array('name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'requirements' => array('something'))
+ ));
+
+ $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', array('something'));
+ }
+
+
/**
* @expectedException \UnexpectedValueException
*/
@@ -85,10 +95,10 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase
* @param string $controllerName
* @param string $actionName
*/
- private function assertSimpleRoute($routes, $name, $verb, $url, $controllerName, $actionName)
+ private function assertSimpleRoute($routes, $name, $verb, $url, $controllerName, $actionName, array $requirements=array())
{
// route mocks
- $route = $this->mockRoute($verb, $controllerName, $actionName);
+ $route = $this->mockRoute($verb, $controllerName, $actionName, $requirements);
// router mock
$router = $this->getMock("\OC\Route\Router", array('create'));
@@ -166,15 +176,15 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase
}
/**
- * @param $verb
- * @param $controllerName
- * @param $actionName
+ * @param string $verb
+ * @param string $controllerName
+ * @param string $actionName
* @return \PHPUnit_Framework_MockObject_MockObject
*/
- private function mockRoute($verb, $controllerName, $actionName)
+ private function mockRoute($verb, $controllerName, $actionName, array $requirements=array())
{
$container = new DIContainer('app1');
- $route = $this->getMock("\OC\Route\Route", array('method', 'action'), array(), '', false);
+ $route = $this->getMock("\OC\Route\Route", array('method', 'action', 'requirements'), array(), '', false);
$route
->expects($this->exactly(1))
->method('method')
@@ -186,6 +196,14 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase
->method('action')
->with($this->equalTo(new RouteActionHandler($container, $controllerName, $actionName)))
->will($this->returnValue($route));
+
+ if(count($requirements) > 0) {
+ $route
+ ->expects($this->exactly(1))
+ ->method('requirements')
+ ->with($this->equalTo($requirements))
+ ->will($this->returnValue($route));
+ }
return $route;
}
diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php
index 11e9fcdf4fa..cfa2d6fd9aa 100644
--- a/tests/lib/dbschema.php
+++ b/tests/lib/dbschema.php
@@ -71,6 +71,9 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase {
$this->assertTableNotExist($this->table2);
}
+ /**
+ * @param string $table
+ */
public function tableExist($table) {
switch (OC_Config::getValue( 'dbtype', 'sqlite' )) {
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php
index 90f1dfe581b..53f528af793 100644
--- a/tests/lib/files/filesystem.php
+++ b/tests/lib/files/filesystem.php
@@ -226,4 +226,55 @@ class Filesystem extends \PHPUnit_Framework_TestCase {
$path = $arguments['path'];
$this->assertEquals($path, \OC\Files\Filesystem::normalizePath($path)); //the path passed to the hook should already be normalized
}
+
+ /**
+ * Test that the default cache dir is part of the user's home
+ */
+ public function testMountDefaultCacheDir() {
+ $userId = uniqid('user_');
+ $oldCachePath = \OC_Config::getValue('cache_path', '');
+ // no cache path configured
+ \OC_Config::setValue('cache_path', '');
+
+ \OC_User::createUser($userId, $userId);
+ \OC\Files\Filesystem::initMountPoints($userId);
+
+ $this->assertEquals(
+ '/' . $userId . '/',
+ \OC\Files\Filesystem::getMountPoint('/' . $userId . '/cache')
+ );
+ list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache');
+ $this->assertInstanceOf('\OC\Files\Storage\Home', $storage);
+ $this->assertEquals('cache', $internalPath);
+ \OC_User::deleteUser($userId);
+
+ \OC_Config::setValue('cache_path', $oldCachePath);
+ }
+
+ /**
+ * Test that an external cache is mounted into
+ * the user's home
+ */
+ public function testMountExternalCacheDir() {
+ $userId = uniqid('user_');
+
+ $oldCachePath = \OC_Config::getValue('cache_path', '');
+ // set cache path to temp dir
+ $cachePath = \OC_Helper::tmpFolder() . '/extcache';
+ \OC_Config::setValue('cache_path', $cachePath);
+
+ \OC_User::createUser($userId, $userId);
+ \OC\Files\Filesystem::initMountPoints($userId);
+
+ $this->assertEquals(
+ '/' . $userId . '/cache/',
+ \OC\Files\Filesystem::getMountPoint('/' . $userId . '/cache')
+ );
+ list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache');
+ $this->assertInstanceOf('\OC\Files\Storage\Local', $storage);
+ $this->assertEquals('', $internalPath);
+ \OC_User::deleteUser($userId);
+
+ \OC_Config::setValue('cache_path', $oldCachePath);
+ }
}
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php
index f9291758606..38cd17ac8c9 100644
--- a/tests/lib/files/storage/storage.php
+++ b/tests/lib/files/storage/storage.php
@@ -64,17 +64,17 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
* @dataProvider directoryProvider
*/
public function testDirectories($directory) {
- $this->assertFalse($this->instance->file_exists('/'.$directory));
+ $this->assertFalse($this->instance->file_exists('/' . $directory));
- $this->assertTrue($this->instance->mkdir('/'.$directory));
+ $this->assertTrue($this->instance->mkdir('/' . $directory));
- $this->assertTrue($this->instance->file_exists('/'.$directory));
- $this->assertTrue($this->instance->is_dir('/'.$directory));
- $this->assertFalse($this->instance->is_file('/'.$directory));
- $this->assertEquals('dir', $this->instance->filetype('/'.$directory));
- $this->assertEquals(0, $this->instance->filesize('/'.$directory));
- $this->assertTrue($this->instance->isReadable('/'.$directory));
- $this->assertTrue($this->instance->isUpdatable('/'.$directory));
+ $this->assertTrue($this->instance->file_exists('/' . $directory));
+ $this->assertTrue($this->instance->is_dir('/' . $directory));
+ $this->assertFalse($this->instance->is_file('/' . $directory));
+ $this->assertEquals('dir', $this->instance->filetype('/' . $directory));
+ $this->assertEquals(0, $this->instance->filesize('/' . $directory));
+ $this->assertTrue($this->instance->isReadable('/' . $directory));
+ $this->assertTrue($this->instance->isUpdatable('/' . $directory));
$dh = $this->instance->opendir('/');
$content = array();
@@ -85,13 +85,13 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
}
$this->assertEquals(array($directory), $content);
- $this->assertFalse($this->instance->mkdir('/'.$directory)); //cant create existing folders
- $this->assertTrue($this->instance->rmdir('/'.$directory));
+ $this->assertFalse($this->instance->mkdir('/' . $directory)); //cant create existing folders
+ $this->assertTrue($this->instance->rmdir('/' . $directory));
$this->wait();
- $this->assertFalse($this->instance->file_exists('/'.$directory));
+ $this->assertFalse($this->instance->file_exists('/' . $directory));
- $this->assertFalse($this->instance->rmdir('/'.$directory)); //cant remove non existing folders
+ $this->assertFalse($this->instance->rmdir('/' . $directory)); //cant remove non existing folders
$dh = $this->instance->opendir('/');
$content = array();
@@ -103,8 +103,7 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
$this->assertEquals(array(), $content);
}
- public function directoryProvider()
- {
+ public function directoryProvider() {
return array(
array('folder'),
array(' folder'),
@@ -113,11 +112,23 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
array('spéciäl földer'),
);
}
+
+ function loremFileProvider() {
+ $root = \OC::$SERVERROOT . '/tests/data/';
+ return array(
+ // small file
+ array($root . 'lorem.txt'),
+ // bigger file (> 8 KB which is the standard PHP block size)
+ array($root . 'lorem-big.txt')
+ );
+ }
+
/**
* test the various uses of file_get_contents and file_put_contents
+ *
+ * @dataProvider loremFileProvider
*/
- public function testGetPutContents() {
- $sourceFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
+ public function testGetPutContents($sourceFile) {
$sourceText = file_get_contents($sourceFile);
//fill a file with string data
@@ -298,4 +309,40 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
$this->assertFalse($this->instance->file_exists('folder/bar'));
$this->assertFalse($this->instance->file_exists('folder'));
}
+
+ public function hashProvider() {
+ return array(
+ array('Foobar', 'md5'),
+ array('Foobar', 'sha1'),
+ array('Foobar', 'sha256'),
+ );
+ }
+
+ /**
+ * @dataProvider hashProvider
+ */
+ public function testHash($data, $type) {
+ $this->instance->file_put_contents('hash.txt', $data);
+ $this->assertEquals(hash($type, $data), $this->instance->hash($type, 'hash.txt'));
+ $this->assertEquals(hash($type, $data, true), $this->instance->hash($type, 'hash.txt', true));
+ }
+
+ public function testHashInFileName() {
+ $this->instance->file_put_contents('#test.txt', 'data');
+ $this->assertEquals('data', $this->instance->file_get_contents('#test.txt'));
+
+ $this->instance->mkdir('#foo');
+ $this->instance->file_put_contents('#foo/test.txt', 'data');
+ $this->assertEquals('data', $this->instance->file_get_contents('#foo/test.txt'));
+
+ $dh = $this->instance->opendir('#foo');
+ $content = array();
+ while ($file = readdir($dh)) {
+ if ($file != '.' and $file != '..') {
+ $content[] = $file;
+ }
+ }
+
+ $this->assertEquals(array('test.txt'), $content);
+ }
}
diff --git a/tests/lib/group/group.php b/tests/lib/group/group.php
index 3982c00e45f..147532f9947 100644
--- a/tests/lib/group/group.php
+++ b/tests/lib/group/group.php
@@ -299,6 +299,68 @@ class Group extends \PHPUnit_Framework_TestCase {
$this->assertEquals('user1', $user1->getUID());
}
+ public function testCountUsers() {
+ $backend1 = $this->getMock('OC_Group_Database');
+ $userManager = $this->getUserManager();
+ $group = new \OC\Group\Group('group1', array($backend1), $userManager);
+
+ $backend1->expects($this->once())
+ ->method('countUsersInGroup')
+ ->with('group1', '2')
+ ->will($this->returnValue(3));
+
+ $backend1->expects($this->any())
+ ->method('implementsActions')
+ ->will($this->returnValue(true));
+
+ $users = $group->count('2');
+
+ $this->assertSame(3, $users);
+ }
+
+ public function testCountUsersMultipleBackends() {
+ $backend1 = $this->getMock('OC_Group_Database');
+ $backend2 = $this->getMock('OC_Group_Database');
+ $userManager = $this->getUserManager();
+ $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager);
+
+ $backend1->expects($this->once())
+ ->method('countUsersInGroup')
+ ->with('group1', '2')
+ ->will($this->returnValue(3));
+ $backend1->expects($this->any())
+ ->method('implementsActions')
+ ->will($this->returnValue(true));
+
+ $backend2->expects($this->once())
+ ->method('countUsersInGroup')
+ ->with('group1', '2')
+ ->will($this->returnValue(4));
+ $backend2->expects($this->any())
+ ->method('implementsActions')
+ ->will($this->returnValue(true));
+
+ $users = $group->count('2');
+
+ $this->assertSame(7, $users);
+ }
+
+ public function testCountUsersNoMethod() {
+ $backend1 = $this->getMock('OC_Group_Database');
+ $userManager = $this->getUserManager();
+ $group = new \OC\Group\Group('group1', array($backend1), $userManager);
+
+ $backend1->expects($this->never())
+ ->method('countUsersInGroup');
+ $backend1->expects($this->any())
+ ->method('implementsActions')
+ ->will($this->returnValue(false));
+
+ $users = $group->count('2');
+
+ $this->assertSame(false, $users);
+ }
+
public function testDelete() {
$backend = $this->getMock('OC_Group_Database');
$userManager = $this->getUserManager();
diff --git a/tests/lib/mail.php b/tests/lib/mail.php
index a88a9d797ae..3cc9868e25e 100644
--- a/tests/lib/mail.php
+++ b/tests/lib/mail.php
@@ -8,6 +8,15 @@
class Test_Mail extends PHPUnit_Framework_TestCase {
+ protected function setUp()
+ {
+ if (!function_exists('idn_to_ascii')) {
+ $this->markTestSkipped(
+ 'The intl extension is not available.'
+ );
+ }
+ }
+
/**
* @dataProvider buildAsciiEmailProvider
* @param $expected
diff --git a/tests/lib/preview.php b/tests/lib/preview.php
index 353b66fd6d6..4ef61fb8257 100644
--- a/tests/lib/preview.php
+++ b/tests/lib/preview.php
@@ -10,66 +10,73 @@ namespace Test;
class Preview extends \PHPUnit_Framework_TestCase {
- public function testIsPreviewDeleted() {
- $user = $this->initFS();
+ /**
+ * @var string
+ */
+ private $user;
+
+ /**
+ * @var \OC\Files\View
+ */
+ private $rootView;
+
+ public function setUp() {
+ $this->user = $this->initFS();
- $rootView = new \OC\Files\View('');
- $rootView->mkdir('/'.$user);
- $rootView->mkdir('/'.$user.'/files');
+ $this->rootView = new \OC\Files\View('');
+ $this->rootView->mkdir('/'.$this->user);
+ $this->rootView->mkdir('/'.$this->user.'/files');
+ }
+
+ public function testIsPreviewDeleted() {
- $samplefile = '/'.$user.'/files/test.txt';
+ $sampleFile = '/'.$this->user.'/files/test.txt';
- $rootView->file_put_contents($samplefile, 'dummy file data');
+ $this->rootView->file_put_contents($sampleFile, 'dummy file data');
$x = 50;
$y = 50;
- $preview = new \OC\Preview($user, 'files/', 'test.txt', $x, $y);
+ $preview = new \OC\Preview($this->user, 'files/', 'test.txt', $x, $y);
$preview->getPreview();
- $fileinfo = $rootView->getFileInfo($samplefile);
- $fileid = $fileinfo['fileid'];
+ $fileInfo = $this->rootView->getFileInfo($sampleFile);
+ $fileId = $fileInfo['fileid'];
- $thumbcachefile = '/' . $user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $x . '-' . $y . '.png';
+ $thumbCacheFile = '/' . $this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/' . $x . '-' . $y . '.png';
- $this->assertEquals($rootView->file_exists($thumbcachefile), true);
+ $this->assertEquals($this->rootView->file_exists($thumbCacheFile), true);
$preview->deletePreview();
- $this->assertEquals($rootView->file_exists($thumbcachefile), false);
+ $this->assertEquals($this->rootView->file_exists($thumbCacheFile), false);
}
public function testAreAllPreviewsDeleted() {
- $user = $this->initFS();
- $rootView = new \OC\Files\View('');
- $rootView->mkdir('/'.$user);
- $rootView->mkdir('/'.$user.'/files');
+ $sampleFile = '/'.$this->user.'/files/test.txt';
- $samplefile = '/'.$user.'/files/test.txt';
-
- $rootView->file_put_contents($samplefile, 'dummy file data');
+ $this->rootView->file_put_contents($sampleFile, 'dummy file data');
$x = 50;
$y = 50;
- $preview = new \OC\Preview($user, 'files/', 'test.txt', $x, $y);
+ $preview = new \OC\Preview($this->user, 'files/', 'test.txt', $x, $y);
$preview->getPreview();
- $fileinfo = $rootView->getFileInfo($samplefile);
- $fileid = $fileinfo['fileid'];
+ $fileInfo = $this->rootView->getFileInfo($sampleFile);
+ $fileId = $fileInfo['fileid'];
- $thumbcachefolder = '/' . $user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileid . '/';
+ $thumbCacheFolder = '/' . $this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/';
- $this->assertEquals($rootView->is_dir($thumbcachefolder), true);
+ $this->assertEquals($this->rootView->is_dir($thumbCacheFolder), true);
$preview->deleteAllPreviews();
- $this->assertEquals($rootView->is_dir($thumbcachefolder), false);
+ $this->assertEquals($this->rootView->is_dir($thumbCacheFolder), false);
}
public function testIsMaxSizeWorking() {
- $user = $this->initFS();
$maxX = 250;
$maxY = 250;
@@ -77,15 +84,11 @@ class Preview extends \PHPUnit_Framework_TestCase {
\OC_Config::setValue('preview_max_x', $maxX);
\OC_Config::setValue('preview_max_y', $maxY);
- $rootView = new \OC\Files\View('');
- $rootView->mkdir('/'.$user);
- $rootView->mkdir('/'.$user.'/files');
-
- $samplefile = '/'.$user.'/files/test.txt';
+ $sampleFile = '/'.$this->user.'/files/test.txt';
- $rootView->file_put_contents($samplefile, 'dummy file data');
+ $this->rootView->file_put_contents($sampleFile, 'dummy file data');
- $preview = new \OC\Preview($user, 'files/', 'test.txt', 1000, 1000);
+ $preview = new \OC\Preview($this->user, 'files/', 'test.txt', 1000, 1000);
$image = $preview->getPreview();
$this->assertEquals($image->width(), $maxX);
@@ -108,18 +111,13 @@ class Preview extends \PHPUnit_Framework_TestCase {
* @dataProvider txtBlacklist
*/
public function testIsTransparent($extension, $data, $expectedResult) {
- $user = $this->initFS();
-
- $rootView = new \OC\Files\View('');
- $rootView->mkdir('/'.$user);
- $rootView->mkdir('/'.$user.'/files');
$x = 32;
$y = 32;
- $sample = '/'.$user.'/files/test.'.$extension;
- $rootView->file_put_contents($sample, $data);
- $preview = new \OC\Preview($user, 'files/', 'test.'.$extension, $x, $y);
+ $sample = '/'.$this->user.'/files/test.'.$extension;
+ $this->rootView->file_put_contents($sample, $data);
+ $preview = new \OC\Preview($this->user, 'files/', 'test.'.$extension, $x, $y);
$image = $preview->getPreview();
$resource = $image->resource();
@@ -133,6 +131,64 @@ class Preview extends \PHPUnit_Framework_TestCase {
);
}
+ public function testCreationFromCached() {
+
+ $sampleFile = '/'.$this->user.'/files/test.txt';
+
+ $this->rootView->file_put_contents($sampleFile, 'dummy file data');
+
+ // create base preview
+ $x = 150;
+ $y = 150;
+
+ $preview = new \OC\Preview($this->user, 'files/', 'test.txt', $x, $y);
+ $preview->getPreview();
+
+ $fileInfo = $this->rootView->getFileInfo($sampleFile);
+ $fileId = $fileInfo['fileid'];
+
+ $thumbCacheFile = '/' . $this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/' . $x . '-' . $y . '.png';
+
+ $this->assertEquals($this->rootView->file_exists($thumbCacheFile), true);
+
+
+ // create smaller previews
+ $preview = new \OC\Preview($this->user, 'files/', 'test.txt', 50, 50);
+ $isCached = $preview->isCached($fileId);
+
+ $this->assertEquals($this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/150-150.png', $isCached);
+ }
+
+ /*
+ public function testScalingUp() {
+
+ $sampleFile = '/'.$this->user.'/files/test.txt';
+
+ $this->rootView->file_put_contents($sampleFile, 'dummy file data');
+
+ // create base preview
+ $x = 150;
+ $y = 150;
+
+ $preview = new \OC\Preview($this->user, 'files/', 'test.txt', $x, $y);
+ $preview->getPreview();
+
+ $fileInfo = $this->rootView->getFileInfo($sampleFile);
+ $fileId = $fileInfo['fileid'];
+
+ $thumbCacheFile = '/' . $this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/' . $x . '-' . $y . '.png';
+
+ $this->assertEquals($this->rootView->file_exists($thumbCacheFile), true);
+
+
+ // create bigger previews - with scale up
+ $preview = new \OC\Preview($this->user, 'files/', 'test.txt', 250, 250);
+ $isCached = $preview->isCached($fileId);
+
+ $this->assertEquals($this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/150-150.png', $isCached);
+ }
+ */
+
private function initFS() {
// create a new user with his own filesystem view
// this gets called by each test in this test class
diff --git a/tests/lib/public/ocpconfig.php b/tests/lib/public/ocpconfig.php
new file mode 100644
index 00000000000..43a9ca625ee
--- /dev/null
+++ b/tests/lib/public/ocpconfig.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2014 Thomas Müller thomas.mueller@tmit.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class Test_OCPConfig extends PHPUnit_Framework_TestCase
+{
+
+ public function testSetAppValueIfSetToNull() {
+
+ $key = uniqid("key-");
+
+ $result = \OCP\Config::setAppValue('unit-test', $key, null);
+ $this->assertTrue($result);
+
+ $result = \OCP\Config::setAppValue('unit-test', $key, '12');
+ $this->assertTrue($result);
+
+ }
+
+}
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index b5cba9430aa..aae91fa1087 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -282,7 +282,7 @@ class Test_Share extends PHPUnit_Framework_TestCase {
OC_User::setUserId($this->user2);
$this->assertEquals(array(OCP\PERMISSION_READ), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS));
OC_User::setUserId($this->user3);
- $this->assertFalse(OCP\Share::getItemSharedWith('test', 'test.txt'));
+ $this->assertSame(array(), OCP\Share::getItemSharedWith('test', 'test.txt'));
// Reshare again, and then have owner unshare
OC_User::setUserId($this->user1);
@@ -292,9 +292,9 @@ class Test_Share extends PHPUnit_Framework_TestCase {
OC_User::setUserId($this->user1);
$this->assertTrue(OCP\Share::unshare('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2));
OC_User::setUserId($this->user2);
- $this->assertFalse(OCP\Share::getItemSharedWith('test', 'test.txt'));
+ $this->assertSame(array(), OCP\Share::getItemSharedWith('test', 'test.txt'));
OC_User::setUserId($this->user3);
- $this->assertFalse(OCP\Share::getItemSharedWith('test', 'test.txt'));
+ $this->assertSame(array(), OCP\Share::getItemSharedWith('test', 'test.txt'));
// Attempt target conflict
OC_User::setUserId($this->user1);
@@ -325,7 +325,7 @@ class Test_Share extends PHPUnit_Framework_TestCase {
);
OC_User::setUserId($this->user2);
- $this->assertFalse(
+ $this->assertSame(array(),
OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
'Failed asserting that user 2 no longer has access to test.txt after expiration.'
);
@@ -526,13 +526,13 @@ class Test_Share extends PHPUnit_Framework_TestCase {
);
OC_User::setUserId($this->user2);
- $this->assertFalse(
+ $this->assertSame(array(),
OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
'Failed asserting that user 2 no longer has access to test.txt after expiration.'
);
OC_User::setUserId($this->user3);
- $this->assertFalse(
+ $this->assertSame(array(),
OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
'Failed asserting that user 3 no longer has access to test.txt after expiration.'
);
diff --git a/tests/lib/urlgenerator.php b/tests/lib/urlgenerator.php
index 875a7f06580..8e605d88f32 100644
--- a/tests/lib/urlgenerator.php
+++ b/tests/lib/urlgenerator.php
@@ -12,17 +12,32 @@ class Test_Urlgenerator extends PHPUnit_Framework_TestCase {
/**
* @small
* @brief test absolute URL construction
- * @dataProvider provideURLs
+ * @dataProvider provideDocRootURLs
*/
- function testGetAbsoluteURL($url, $expectedResult) {
+ function testGetAbsoluteURLDocRoot($url, $expectedResult) {
+ \OC::$WEBROOT = '';
$urlGenerator = new \OC\URLGenerator(null);
$result = $urlGenerator->getAbsoluteURL($url);
$this->assertEquals($expectedResult, $result);
}
- public function provideURLs() {
+ /**
+ * @small
+ * @brief test absolute URL construction
+ * @dataProvider provideSubDirURLs
+ */
+ function testGetAbsoluteURLSubDir($url, $expectedResult) {
+
+ \OC::$WEBROOT = '/owncloud';
+ $urlGenerator = new \OC\URLGenerator(null);
+ $result = $urlGenerator->getAbsoluteURL($url);
+
+ $this->assertEquals($expectedResult, $result);
+ }
+
+ public function provideDocRootURLs() {
return array(
array("index.php", "http://localhost/index.php"),
array("/index.php", "http://localhost/index.php"),
@@ -30,5 +45,14 @@ class Test_Urlgenerator extends PHPUnit_Framework_TestCase {
array("apps/index.php", "http://localhost/apps/index.php"),
);
}
+
+ public function provideSubDirURLs() {
+ return array(
+ array("index.php", "http://localhost/owncloud/index.php"),
+ array("/index.php", "http://localhost/owncloud/index.php"),
+ array("/apps/index.php", "http://localhost/owncloud/apps/index.php"),
+ array("apps/index.php", "http://localhost/owncloud/apps/index.php"),
+ );
+ }
}