summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-07-23 22:06:03 +0200
committerRobin Appelman <icewind@owncloud.com>2013-07-23 22:06:03 +0200
commitfb40d9e1e65ea5f23bdaa534dbb1b3758d8c2cbd (patch)
tree48bfa8512b49a3e168fa01d68260599735fb9f35 /tests
parente3ea3ed3c563fce2b5fe1addfe199e3aaec7abdb (diff)
parent7ad38535e51812e08042e46bd550aa9cc5781955 (diff)
downloadnextcloud-server-fb40d9e1e65ea5f23bdaa534dbb1b3758d8c2cbd.tar.gz
nextcloud-server-fb40d9e1e65ea5f23bdaa534dbb1b3758d8c2cbd.zip
Merge branch 'master' into groups
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/cache/apc.php35
-rw-r--r--tests/lib/cache/xcache.php31
-rw-r--r--tests/lib/config.php96
-rw-r--r--tests/lib/db.php4
-rw-r--r--tests/lib/files/storage/storage.php18
-rw-r--r--tests/lib/files/view.php9
-rw-r--r--tests/lib/helper.php60
-rw-r--r--tests/lib/hooks/forwardingemitter.php74
-rw-r--r--tests/lib/memcache/apc.php20
-rw-r--r--tests/lib/memcache/cache.php58
-rw-r--r--tests/lib/memcache/memcached.php20
-rw-r--r--tests/lib/memcache/xcache.php20
-rw-r--r--tests/lib/util.php6
13 files changed, 374 insertions, 77 deletions
diff --git a/tests/lib/cache/apc.php b/tests/lib/cache/apc.php
deleted file mode 100644
index bb5eb483dbf..00000000000
--- a/tests/lib/cache/apc.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
-* ownCloud
-*
-* @author Robin Appelman
-* @copyright 2012 Robin Appelman icewind@owncloud.com
-*
-* 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_Cache_APC extends Test_Cache {
- public function setUp() {
- if(!extension_loaded('apc')) {
- $this->markTestSkipped('The apc extension is not available.');
- return;
- }
- if(!ini_get('apc.enable_cli') && OC::$CLI) {
- $this->markTestSkipped('apc not available in CLI.');
- return;
- }
- $this->instance=new OC_Cache_APC();
- }
-}
diff --git a/tests/lib/cache/xcache.php b/tests/lib/cache/xcache.php
deleted file mode 100644
index 43bed2db037..00000000000
--- a/tests/lib/cache/xcache.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
-* ownCloud
-*
-* @author Robin Appelman
-* @copyright 2012 Robin Appelman icewind@owncloud.com
-*
-* 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_Cache_XCache extends Test_Cache {
- public function setUp() {
- if(!function_exists('xcache_get')) {
- $this->markTestSkipped('The xcache extension is not available.');
- return;
- }
- $this->instance=new OC_Cache_XCache();
- }
-}
diff --git a/tests/lib/config.php b/tests/lib/config.php
new file mode 100644
index 00000000000..1a1d062d688
--- /dev/null
+++ b/tests/lib/config.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+class Test_Config extends PHPUnit_Framework_TestCase {
+ const CONFIG_FILE = 'static://config.php';
+ const CONFIG_DIR = 'static://';
+ const TESTCONTENT = '<?php $CONFIG=array("foo"=>"bar");';
+
+ /**
+ * @var \OC\Config
+ */
+ private $config;
+
+ function setUp() {
+ file_put_contents(self::CONFIG_FILE, self::TESTCONTENT);
+ $this->config = new OC\Config(self::CONFIG_DIR);
+ }
+
+ public function testReadData() {
+ $config = new OC\Config('/non-existing');
+ $this->assertAttributeEquals(array(), 'cache', $config);
+
+ $this->assertAttributeEquals(array('foo' => 'bar'), 'cache', $this->config);
+ }
+
+ public function testGetKeys() {
+ $this->assertEquals(array('foo'), $this->config->getKeys());
+ }
+
+ public function testGetValue() {
+ $this->assertEquals('bar', $this->config->getValue('foo'));
+ $this->assertEquals(null, $this->config->getValue('bar'));
+ $this->assertEquals('moo', $this->config->getValue('bar', 'moo'));
+ }
+
+ public function testSetValue() {
+ $this->config->setDebugMode(false);
+ $this->config->setValue('foo', 'moo');
+ $this->assertAttributeEquals(array('foo' => 'moo'), 'cache', $this->config);
+ $content = file_get_contents(self::CONFIG_FILE);
+
+ $expected = "<?php\n\$CONFIG = array (\n 'foo' => 'moo',\n);\n";
+ $this->assertEquals($expected, $content);
+ $this->config->setValue('bar', 'red');
+ $this->assertAttributeEquals(array('foo' => 'moo', 'bar' => 'red'), 'cache', $this->config);
+ $content = file_get_contents(self::CONFIG_FILE);
+
+ $expected = "<?php\n\$CONFIG = array (\n 'foo' => 'moo',\n 'bar' => 'red',\n);\n";
+ $this->assertEquals($expected, $content);
+ }
+
+ public function testDeleteKey() {
+ $this->config->setDebugMode(false);
+ $this->config->deleteKey('foo');
+ $this->assertAttributeEquals(array(), 'cache', $this->config);
+ $content = file_get_contents(self::CONFIG_FILE);
+
+ $expected = "<?php\n\$CONFIG = array (\n);\n";
+ $this->assertEquals($expected, $content);
+ }
+
+ public function testSavingDebugMode() {
+ $this->config->setDebugMode(true);
+ $this->config->deleteKey('foo'); // change something so we save to the config file
+ $this->assertAttributeEquals(array(), 'cache', $this->config);
+ $this->assertAttributeEquals(true, 'debugMode', $this->config);
+ $content = file_get_contents(self::CONFIG_FILE);
+
+ $expected = "<?php\ndefine('DEBUG',true);\n\$CONFIG = array (\n);\n";
+ $this->assertEquals($expected, $content);
+ }
+
+ /**
+ * @expectedException \OC\HintException
+ */
+ public function testWriteData() {
+ $config = new OC\Config('/non-writable');
+ // TODO never get's called, because the previous call throws the exception
+ // maybe include some more logic to create a readable dir and then try to
+ // write to this dir
+ //
+ // console commands:
+ // $ sudo touch /non-writableconfig.php
+ // $ sudo chmod go-rwx /non-writableconfig.php
+ // ---- call the tests now -> above statemant throws the exception
+ //
+ // $ sudo chmod go+r /non-writableconfig.php
+ // ---- call the tests now -> bellow statemant throws the exception
+ $config->setValue('foo', 'bar');
+ }
+}
diff --git a/tests/lib/db.php b/tests/lib/db.php
index 69e3542f926..e817a2db5ed 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db.php
@@ -37,7 +37,7 @@ class Test_DB extends PHPUnit_Framework_TestCase {
$result = $query->execute(array('uri_1'));
$this->assertTrue((bool)$result);
$row = $result->fetchRow();
- $this->assertFalse((bool)$row); //PDO returns false, MDB2 returns null
+ $this->assertFalse($row);
$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
$result = $query->execute(array('fullname test', 'uri_1'));
$this->assertEquals(1, $result);
@@ -94,7 +94,7 @@ class Test_DB extends PHPUnit_Framework_TestCase {
$query = OC_DB::prepare('SELECT * FROM `*PREFIX*'.$this->table3.'`');
$result = $query->execute();
$this->assertTrue((bool)$result);
- $this->assertEquals(4, $result->numRows());
+ $this->assertEquals(4, count($result->fetchAll()));
}
public function testinsertIfNotExistDontOverwrite() {
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php
index fb3e05e66b3..fbf502fbc1c 100644
--- a/tests/lib/files/storage/storage.php
+++ b/tests/lib/files/storage/storage.php
@@ -168,10 +168,10 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
$this->assertTrue($this->instance->isReadable('/lorem.txt'));
$ctimeEnd = time();
$mTime = $this->instance->filemtime('/lorem.txt');
- $this->assertTrue($this->instance->hasUpdated('/lorem.txt', $ctimeStart - 1));
- $this->assertTrue($this->instance->hasUpdated('/', $ctimeStart - 1));
+ $this->assertTrue($this->instance->hasUpdated('/lorem.txt', $ctimeStart - 5));
+ $this->assertTrue($this->instance->hasUpdated('/', $ctimeStart - 5));
- $this->assertTrue(($ctimeStart - 1) <= $mTime);
+ $this->assertTrue(($ctimeStart - 5) <= $mTime);
$this->assertTrue($mTime <= ($ctimeEnd + 1));
$this->assertEquals(filesize($textFile), $this->instance->filesize('/lorem.txt'));
@@ -185,10 +185,10 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
$mtimeEnd = time();
if ($supportsTouch !== false) {
$mTime = $this->instance->filemtime('/lorem.txt');
- $this->assertTrue(($mtimeStart - 1) <= $mTime);
- $this->assertTrue($mTime <= ($mtimeEnd + 1));
+ $this->assertTrue(($mtimeStart - 5) <= $mTime);
+ $this->assertTrue($mTime <= ($mtimeEnd + 5));
- $this->assertTrue($this->instance->hasUpdated('/lorem.txt', $mtimeStart - 1));
+ $this->assertTrue($this->instance->hasUpdated('/lorem.txt', $mtimeStart - 5));
if ($this->instance->touch('/lorem.txt', 100) !== false) {
$mTime = $this->instance->filemtime('/lorem.txt');
@@ -203,11 +203,11 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
clearstatcache();
$mtimeEnd = time();
$mTime = $this->instance->filemtime('/lorem.txt');
- $this->assertTrue(($mtimeStart - 1) <= $mTime);
- $this->assertTrue($mTime <= ($mtimeEnd + 1));
+ $this->assertTrue(($mtimeStart - 5) <= $mTime);
+ $this->assertTrue($mTime <= ($mtimeEnd + 5));
$this->instance->unlink('/lorem.txt');
- $this->assertTrue($this->instance->hasUpdated('/', $mtimeStart - 1));
+ $this->assertTrue($this->instance->hasUpdated('/', $mtimeStart - 5));
}
public function testSearch() {
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 830913a91ad..3bac9e770aa 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -20,10 +20,19 @@ class View extends \PHPUnit_Framework_TestCase {
private $storages = array();
public function setUp() {
+ \OC_User::clearBackends();
+ \OC_User::useBackend(new \OC_User_Dummy());
+
+ //login
+ \OC_User::createUser('test', 'test');
+ $this->user=\OC_User::getUser();
+ \OC_User::setUserId('test');
+
\OC\Files\Filesystem::clearMounts();
}
public function tearDown() {
+ \OC_User::setUserId($this->user);
foreach ($this->storages as $storage) {
$cache = $storage->getCache();
$ids = $cache->getAll();
diff --git a/tests/lib/helper.php b/tests/lib/helper.php
index 6acb0dfaa6b..67b5a3d43ec 100644
--- a/tests/lib/helper.php
+++ b/tests/lib/helper.php
@@ -146,4 +146,64 @@ class Test_Helper extends PHPUnit_Framework_TestCase {
$result = OC_Helper::recursiveArraySearch($haystack, "NotFound");
$this->assertFalse($result);
}
+
+ function testBuildNotExistingFileNameForView() {
+ $viewMock = $this->getMock('\OC\Files\View', array(), array(), '', false);
+ $this->assertEquals('/filename', OC_Helper::buildNotExistingFileNameForView('/', 'filename', $viewMock));
+ $this->assertEquals('dir/filename.ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename.ext', $viewMock));
+
+ $viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename.ext exists
+ $this->assertEquals('dir/filename (2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename.ext', $viewMock));
+
+ $viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename.ext exists
+ $viewMock->expects($this->at(1))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename (2).ext exists
+ $this->assertEquals('dir/filename (3).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename.ext', $viewMock));
+
+ $viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename (1).ext exists
+ $this->assertEquals('dir/filename (2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename (1).ext', $viewMock));
+
+ $viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename (2).ext exists
+ $this->assertEquals('dir/filename (3).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename (2).ext', $viewMock));
+
+ $viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename (2).ext exists
+ $viewMock->expects($this->at(1))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename (3).ext exists
+ $this->assertEquals('dir/filename (4).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename (2).ext', $viewMock));
+
+ $viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename(1).ext exists
+ $this->assertEquals('dir/filename(2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1).ext', $viewMock));
+
+ $viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename(1) (1).ext exists
+ $this->assertEquals('dir/filename(1) (2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1) (1).ext', $viewMock));
+
+ $viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename(1) (1).ext exists
+ $viewMock->expects($this->at(1))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename(1) (2).ext exists
+ $this->assertEquals('dir/filename(1) (3).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1) (1).ext', $viewMock));
+
+ $viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->will($this->returnValue(true)); // filename(1) (2) (3).ext exists
+ $this->assertEquals('dir/filename(1) (2) (4).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1) (2) (3).ext', $viewMock));
+ }
}
diff --git a/tests/lib/hooks/forwardingemitter.php b/tests/lib/hooks/forwardingemitter.php
new file mode 100644
index 00000000000..decf6bb354c
--- /dev/null
+++ b/tests/lib/hooks/forwardingemitter.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Hooks;
+use OC\Hooks\PublicEmitter;
+
+class DummyForwardingEmitter extends \OC\Hooks\ForwardingEmitter {
+ public function emitEvent($scope, $method, $arguments = array()) {
+ $this->emit($scope, $method, $arguments);
+ }
+
+ /**
+ * @param \OC\Hooks\Emitter $emitter
+ */
+ public function forward($emitter) {
+ parent::forward($emitter);
+ }
+}
+
+/**
+ * Class ForwardingEmitter
+ *
+ * allows forwarding all listen calls to other emitters
+ *
+ * @package OC\Hooks
+ */
+class ForwardingEmitter extends BasicEmitter {
+ public function testSingleForward() {
+ $baseEmitter = new PublicEmitter();
+ $forwardingEmitter = new DummyForwardingEmitter();
+ $forwardingEmitter->forward($baseEmitter);
+ $hookCalled = false;
+ $forwardingEmitter->listen('Test', 'test', function () use (&$hookCalled) {
+ $hookCalled = true;
+ });
+ $baseEmitter->emit('Test', 'test');
+ $this->assertTrue($hookCalled);
+ }
+
+ public function testMultipleForwards() {
+ $baseEmitter1 = new PublicEmitter();
+ $baseEmitter2 = new PublicEmitter();
+ $forwardingEmitter = new DummyForwardingEmitter();
+ $forwardingEmitter->forward($baseEmitter1);
+ $forwardingEmitter->forward($baseEmitter2);
+ $hookCalled = 0;
+ $forwardingEmitter->listen('Test', 'test1', function () use (&$hookCalled) {
+ $hookCalled++;
+ });
+ $forwardingEmitter->listen('Test', 'test2', function () use (&$hookCalled) {
+ $hookCalled++;
+ });
+ $baseEmitter1->emit('Test', 'test1');
+ $baseEmitter1->emit('Test', 'test2');
+ $this->assertEquals(2, $hookCalled);
+ }
+
+ public function testForwardExistingHooks() {
+ $baseEmitter = new PublicEmitter();
+ $forwardingEmitter = new DummyForwardingEmitter();
+ $hookCalled = false;
+ $forwardingEmitter->listen('Test', 'test', function () use (&$hookCalled) {
+ $hookCalled = true;
+ });
+ $forwardingEmitter->forward($baseEmitter);
+ $baseEmitter->emit('Test', 'test');
+ $this->assertTrue($hookCalled);
+ }
+}
diff --git a/tests/lib/memcache/apc.php b/tests/lib/memcache/apc.php
new file mode 100644
index 00000000000..6b2a49470ba
--- /dev/null
+++ b/tests/lib/memcache/apc.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Memcache;
+
+class APC extends Cache {
+ public function setUp() {
+ if(!\OC\Memcache\APC::isAvailable()) {
+ $this->markTestSkipped('The apc extension is not available.');
+ return;
+ }
+ $this->instance=new \OC\Memcache\APC(uniqid());
+ }
+}
diff --git a/tests/lib/memcache/cache.php b/tests/lib/memcache/cache.php
new file mode 100644
index 00000000000..d07c492cef0
--- /dev/null
+++ b/tests/lib/memcache/cache.php
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Memcache;
+
+abstract class Cache extends \Test_Cache {
+ public function testExistsAfterSet() {
+ $this->assertFalse($this->instance->hasKey('foo'));
+ $this->instance->set('foo', 'bar');
+ $this->assertTrue($this->instance->hasKey('foo'));
+ }
+
+ public function testGetAfterSet() {
+ $this->assertNull($this->instance->get('foo'));
+ $this->instance->set('foo', 'bar');
+ $this->assertEquals('bar', $this->instance->get('foo'));
+ }
+
+ public function testDoesNotExistAfterRemove() {
+ $this->instance->set('foo', 'bar');
+ $this->instance->remove('foo');
+ $this->assertFalse($this->instance->hasKey('foo'));
+ }
+
+ public function testArrayAccessSet() {
+ $this->instance['foo'] = 'bar';
+ $this->assertEquals('bar', $this->instance->get('foo'));
+ }
+
+ public function testArrayAccessGet() {
+ $this->instance->set('foo', 'bar');
+ $this->assertEquals('bar', $this->instance['foo']);
+ }
+
+ public function testArrayAccessExists() {
+ $this->assertFalse(isset($this->instance['foo']));
+ $this->instance->set('foo', 'bar');
+ $this->assertTrue(isset($this->instance['foo']));
+ }
+
+ public function testArrayAccessUnset() {
+ $this->instance->set('foo', 'bar');
+ unset($this->instance['foo']);
+ $this->assertFalse($this->instance->hasKey('foo'));
+ }
+
+ public function tearDown() {
+ if ($this->instance) {
+ $this->instance->clear();
+ }
+ }
+}
diff --git a/tests/lib/memcache/memcached.php b/tests/lib/memcache/memcached.php
new file mode 100644
index 00000000000..4b38ae8ef3c
--- /dev/null
+++ b/tests/lib/memcache/memcached.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Memcache;
+
+class Memcached extends Cache {
+ public function setUp() {
+ if (!\OC\Memcache\Memcached::isAvailable()) {
+ $this->markTestSkipped('The memcached extension is not available.');
+ return;
+ }
+ $this->instance = new \OC\Memcache\Memcached(uniqid());
+ }
+}
diff --git a/tests/lib/memcache/xcache.php b/tests/lib/memcache/xcache.php
new file mode 100644
index 00000000000..f59afda3966
--- /dev/null
+++ b/tests/lib/memcache/xcache.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Memcache;
+
+class XCache extends Cache {
+ public function setUp() {
+ if (!\OC\Memcache\XCache::isAvailable()) {
+ $this->markTestSkipped('The xcache extension is not available.');
+ return;
+ }
+ $this->instance = new \OC\Memcache\XCache(uniqid());
+ }
+}
diff --git a/tests/lib/util.php b/tests/lib/util.php
index 1f253825920..9742d57ac7a 100644
--- a/tests/lib/util.php
+++ b/tests/lib/util.php
@@ -37,6 +37,12 @@ class Test_Util extends PHPUnit_Framework_TestCase {
$result = OC_Util::sanitizeHTML($goodString);
$this->assertEquals("This is an harmless string.", $result);
}
+
+ function testEncodePath(){
+ $component = '/§#@test%&^ä/-child';
+ $result = OC_Util::encodePath($component);
+ $this->assertEquals("/%C2%A7%23%40test%25%26%5E%C3%A4/-child", $result);
+ }
function testGenerate_random_bytes() {
$result = strlen(OC_Util::generate_random_bytes(59));