some test cases for fopen of storage backends

This commit is contained in:
Robin Appelman 2012-10-11 19:38:32 +02:00
parent c4e301d48f
commit 29c43b7d61
1 changed files with 20 additions and 0 deletions

View File

@ -221,4 +221,24 @@ abstract class Test_FileStorage extends UnitTestCase {
$this->assertContains('/logo-wide.svg', $result);
$this->assertContains('/logo-wide.png', $result);
}
public function testFOpen() {
$textFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
$fh = @$this->instance->fopen('foo', 'r');
if ($fh) {
fclose($fh);
}
$this->assertFalse($fh);
$this->assertFalse($this->instance->file_exists('foo'));
$fh = $this->instance->fopen('foo', 'w');
fwrite($fh, file_get_contents($textFile));
fclose($fh);
$this->assertTrue($this->instance->file_exists('foo'));
$fh = $this->instance->fopen('foo', 'r');
$content = stream_get_contents($fh);
$this->assertEqual(file_get_contents($textFile), $content);
}
}