summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/autoloader.php19
-rw-r--r--tests/lib/files/cache/updater.php5
-rw-r--r--tests/lib/files/mapper.php52
3 files changed, 74 insertions, 2 deletions
diff --git a/tests/lib/autoloader.php b/tests/lib/autoloader.php
new file mode 100644
index 00000000000..e769bf3bcf6
--- /dev/null
+++ b/tests/lib/autoloader.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Müller <thomas.mueller@tmit.eu>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+class Test_AutoLoader extends PHPUnit_Framework_TestCase {
+
+ public function testLeadingSlashOnClassName(){
+ $this->assertTrue(class_exists('\OC\Files\Storage\Local'));
+ }
+
+ public function testNoLeadingSlashOnClassName(){
+ $this->assertTrue(class_exists('OC\Files\Storage\Local'));
+ }
+
+}
diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php
index 7a79f45a203..aaf932c97fe 100644
--- a/tests/lib/files/cache/updater.php
+++ b/tests/lib/files/cache/updater.php
@@ -54,6 +54,8 @@ class Updater extends \PHPUnit_Framework_TestCase {
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
+ \OC_Hook::clear('OC_Filesystem');
+
\OC_Hook::connect('OC_Filesystem', 'post_write', '\OC\Files\Cache\Updater', 'writeHook');
\OC_Hook::connect('OC_Filesystem', 'post_delete', '\OC\Files\Cache\Updater', 'deleteHook');
\OC_Hook::connect('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Updater', 'renameHook');
@@ -137,11 +139,10 @@ class Updater extends \PHPUnit_Framework_TestCase {
$this->assertFalse($this->cache->inCache('foo.txt'));
$this->assertTrue($this->cache->inCache('bar.txt'));
$cachedData = $this->cache->get('bar.txt');
- $this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($fooCachedData['fileid'], $cachedData['fileid']);
$mtime = $cachedData['mtime'];
$cachedData = $this->cache->get('');
$this->assertEquals(3 * $textSize + $imageSize, $cachedData['size']);
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
- $this->assertEquals($mtime, $cachedData['mtime']);
}
}
diff --git a/tests/lib/files/mapper.php b/tests/lib/files/mapper.php
new file mode 100644
index 00000000000..e3859bc0f23
--- /dev/null
+++ b/tests/lib/files/mapper.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller thomas.mueller@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/>.
+ *
+ */
+
+namespace Test\Files;
+
+class Mapper extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var \OC\Files\Mapper
+ */
+ private $mapper = null;
+
+ public function setUp() {
+ $this->mapper = new \OC\Files\Mapper('D:/');
+ }
+
+ public function testSlugifyPath() {
+ // with extension
+ $this->assertEquals('D:/text.txt', $this->mapper->slugifyPath('D:/text.txt'));
+ $this->assertEquals('D:/text-2.txt', $this->mapper->slugifyPath('D:/text.txt', 2));
+ $this->assertEquals('D:/a/b/text.txt', $this->mapper->slugifyPath('D:/a/b/text.txt'));
+
+ // without extension
+ $this->assertEquals('D:/text', $this->mapper->slugifyPath('D:/text'));
+ $this->assertEquals('D:/text-2', $this->mapper->slugifyPath('D:/text', 2));
+ $this->assertEquals('D:/a/b/text', $this->mapper->slugifyPath('D:/a/b/text'));
+
+ // with double dot
+ $this->assertEquals('D:/text-text.txt', $this->mapper->slugifyPath('D:/text.text.txt'));
+ $this->assertEquals('D:/text-text-2.txt', $this->mapper->slugifyPath('D:/text.text.txt', 2));
+ $this->assertEquals('D:/a/b/text-text.txt', $this->mapper->slugifyPath('D:/a/b/text.text.txt'));
+ }
+}