diff options
author | Robin Appelman <robin@icewind.nl> | 2022-08-16 17:24:06 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2022-10-06 14:28:00 +0200 |
commit | 6023dee5aeecf157454af21fa9d600f867500c72 (patch) | |
tree | 9bf6ce924c4fd44aa1b1b5b93909f8b2c22d9846 | |
parent | 3aabb381b9e7ffc5b13f951b8fb89494fe903a2c (diff) | |
download | nextcloud-server-6023dee5aeecf157454af21fa9d600f867500c72.tar.gz nextcloud-server-6023dee5aeecf157454af21fa9d600f867500c72.zip |
add test for trying to fopen a file which no longer exists on disk
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | apps/dav/tests/unit/Connector/Sabre/FileTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Files/ViewTest.php | 19 |
2 files changed, 21 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index 9870a62845c..81d1f71aedf 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -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); diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 7b735720ff1..d33007cfa8a 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -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')); + } } |