aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/files/cache
diff options
context:
space:
mode:
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();
+ }
+}