Skip to content

Commit 1de0b10

Browse files
committed
add test for trying to fopen a file which no longer exists on disk
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent a880f79 commit 1de0b10

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

apps/dav/tests/unit/Connector/Sabre/FileTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ public function testGetFopenFails() {
11511151

11521152
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
11531153
'permissions' => \OCP\Constants::PERMISSION_ALL,
1154-
'type' => FileInfo::TYPE_FOLDER,
1154+
'type' => FileInfo::TYPE_FILE,
11551155
], null);
11561156

11571157
$file = new \OCA\DAV\Connector\Sabre\File($view, $info);
@@ -1172,7 +1172,7 @@ public function testGetFopenThrows() {
11721172

11731173
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
11741174
'permissions' => \OCP\Constants::PERMISSION_ALL,
1175-
'type' => FileInfo::TYPE_FOLDER,
1175+
'type' => FileInfo::TYPE_FILE,
11761176
], null);
11771177

11781178
$file = new \OCA\DAV\Connector\Sabre\File($view, $info);

tests/lib/Files/ViewTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,4 +2709,23 @@ public function testCacheExtension() {
27092709
$this->assertEquals(25, $info->getUploadTime());
27102710
$this->assertEquals(0, $info->getCreationTime());
27112711
}
2712+
2713+
public function testFopenGone() {
2714+
$storage = new Temporary([]);
2715+
$scanner = $storage->getScanner();
2716+
$storage->file_put_contents('foo.txt', 'bar');
2717+
$scanner->scan('');
2718+
$cache = $storage->getCache();
2719+
2720+
Filesystem::mount($storage, [], '/test/');
2721+
$view = new View('/test');
2722+
2723+
$storage->unlink('foo.txt');
2724+
2725+
$this->assertTrue($cache->inCache('foo.txt'));
2726+
2727+
$this->assertFalse($view->fopen('foo.txt', 'r'));
2728+
2729+
$this->assertFalse($cache->inCache('foo.txt'));
2730+
}
27122731
}

0 commit comments

Comments
 (0)