summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-01-20 12:59:57 +0100
committerRobin Appelman <icewind@owncloud.com>2015-01-29 15:39:56 +0100
commit2124540d1d9f500423e5149b1490ed489788ff1d (patch)
tree4fc91496246e020c477557e1e4133e689cb59c29 /tests
parent65ec950b27d625b8184fbff28ecb7778f55415d9 (diff)
downloadnextcloud-server-2124540d1d9f500423e5149b1490ed489788ff1d.tar.gz
nextcloud-server-2124540d1d9f500423e5149b1490ed489788ff1d.zip
Dont remove a file from cache if the delete operation failed
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/view.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 5e42e5ffd0f..9ddc9c80475 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -849,4 +849,27 @@ class View extends \Test\TestCase {
$this->assertEquals($time, $view->filemtime('/test/sub/storage/foo/bar.txt'));
}
+
+ public function testDeleteFailKeepCache() {
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject | \OC\Files\Storage\Temporary $storage
+ */
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
+ ->setConstructorArgs(array(array()))
+ ->setMethods(array('unlink'))
+ ->getMock();
+ $storage->expects($this->once())
+ ->method('unlink')
+ ->will($this->returnValue(false));
+ $scanner = $storage->getScanner();
+ $cache = $storage->getCache();
+ $storage->file_put_contents('foo.txt', 'asd');
+ $scanner->scan('');
+ \OC\Files\Filesystem::mount($storage, array(), '/test/');
+
+ $view = new \OC\Files\View('/test');
+
+ $this->assertFalse($view->unlink('foo.txt'));
+ $this->assertTrue($cache->inCache('foo.txt'));
+ }
}