Browse Source

add test for trying to fopen a file which no longer exists on disk

Signed-off-by: Robin Appelman <robin@icewind.nl>
tags/v26.0.0beta1
Robin Appelman 1 year ago
parent
commit
1de0b10751
2 changed files with 21 additions and 2 deletions
  1. 2
    2
      apps/dav/tests/unit/Connector/Sabre/FileTest.php
  2. 19
    0
      tests/lib/Files/ViewTest.php

+ 2
- 2
apps/dav/tests/unit/Connector/Sabre/FileTest.php View 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);

+ 19
- 0
tests/lib/Files/ViewTest.php View File

@@ -2709,4 +2709,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'));
}
}

Loading…
Cancel
Save