]> source.dussan.org Git - nextcloud-server.git/commitdiff
add test for trying to fopen a file which no longer exists on disk
authorRobin Appelman <robin@icewind.nl>
Tue, 16 Aug 2022 15:24:06 +0000 (17:24 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 6 Oct 2022 12:28:00 +0000 (14:28 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/dav/tests/unit/Connector/Sabre/FileTest.php
tests/lib/Files/ViewTest.php

index 9870a62845c72e4904ba00489a58674375468b7e..81d1f71aedf2c370cf98d8e4ff011074c024e392 100644 (file)
@@ -1151,7 +1151,7 @@ class FileTest extends TestCase {
 
                $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
                        'permissions' => \OCP\Constants::PERMISSION_ALL,
-                       'type' => FileInfo::TYPE_FOLDER,
+                       'type' => FileInfo::TYPE_FILE,
                ], null);
 
                $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
@@ -1172,7 +1172,7 @@ class FileTest extends TestCase {
 
                $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
                        'permissions' => \OCP\Constants::PERMISSION_ALL,
-                       'type' => FileInfo::TYPE_FOLDER,
+                       'type' => FileInfo::TYPE_FILE,
                ], null);
 
                $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
index 7b735720ff13bcfe5cfb63a11e15ac8e77b8b92c..d33007cfa8a2bf663976d17474949631f33fe74c 100644 (file)
@@ -2722,4 +2722,23 @@ class ViewTest extends \Test\TestCase {
                $this->assertEquals(25, $info->getUploadTime());
                $this->assertEquals(0, $info->getCreationTime());
        }
+
+       public function testFopenGone() {
+               $storage = new Temporary([]);
+               $scanner = $storage->getScanner();
+               $storage->file_put_contents('foo.txt', 'bar');
+               $scanner->scan('');
+               $cache = $storage->getCache();
+
+               Filesystem::mount($storage, [], '/test/');
+               $view = new View('/test');
+
+               $storage->unlink('foo.txt');
+
+               $this->assertTrue($cache->inCache('foo.txt'));
+
+               $this->assertFalse($view->fopen('foo.txt', 'r'));
+
+               $this->assertFalse($cache->inCache('foo.txt'));
+       }
 }