aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/files/cache
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-10-03 11:24:49 +0200
committerRobin Appelman <icewind@owncloud.com>2012-10-03 11:24:49 +0200
commite415e90c6d8a2e8bb129be7c63a7077c56ab3da8 (patch)
tree4c56e20836329e3d2e47008475b2860f4b69c852 /tests/lib/files/cache
parent96d7cd59978cc416bc0d9c5ac487af23692ef1d8 (diff)
downloadnextcloud-server-e415e90c6d8a2e8bb129be7c63a7077c56ab3da8.tar.gz
nextcloud-server-e415e90c6d8a2e8bb129be7c63a7077c56ab3da8.zip
make filestorage scanner non-static and add a simple test case
Diffstat (limited to 'tests/lib/files/cache')
-rw-r--r--tests/lib/files/cache/cache.php1
-rw-r--r--tests/lib/files/cache/scanner.php47
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index 48cdc1c8c8c..8cedadbf19a 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -34,6 +34,7 @@ class Cache extends \UnitTestCase {
foreach ($data1 as $key => $value) {
$this->assertEqual($value, $cacheData1[$key]);
}
+ $this->assertEqual($cacheData1['mimepart'], 'foo');
$this->assertEqual($cacheData1['fileid'], $id1);
$this->assertEqual($id1, $this->cache->getId($file1));
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php
new file mode 100644
index 00000000000..3d1c1546ab0
--- /dev/null
+++ b/tests/lib/files/cache/scanner.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Copyright (c) 2012 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\Files\Cache;
+
+class Scanner extends \UnitTestCase {
+ /**
+ * @var \OC\Files\Storage\Storage $storage
+ */
+ private $storage;
+
+ /**
+ * @var \OC\Files\Cache\Scanner $scanner
+ */
+ private $scanner;
+
+ /**
+ * @var \OC\Files\Cache\Cache $cache
+ */
+ private $cache;
+
+ function testFile() {
+ $data = "dummy file data\n";
+ $this->storage->file_put_contents('foo.txt', $data);
+ $this->scanner->scanFile('foo.txt');
+
+ $this->assertEqual($this->cache->inCache('foo.txt'), true);
+ $cachedData = $this->cache->get('foo.txt');
+ $this->assertEqual($cachedData['size'], strlen($data));
+ $this->assertEqual($cachedData['mimetype'], 'text/plain');
+ }
+
+ function setUp() {
+ $this->storage = new \OC\Files\Storage\Temporary(array());
+ $this->scanner = new \OC\Files\Cache\Scanner($this->storage);
+ $this->cache = new \OC\Files\Cache\Cache($this->storage);
+ }
+
+ function tearDown() {
+// $this->cache->clear();
+ }
+}