]> source.dussan.org Git - nextcloud-server.git/commitdiff
some test cases for fopen of storage backends
authorRobin Appelman <icewind@owncloud.com>
Thu, 11 Oct 2012 17:38:32 +0000 (19:38 +0200)
committerRobin Appelman <icewind@owncloud.com>
Thu, 11 Oct 2012 20:18:34 +0000 (22:18 +0200)
tests/lib/filestorage.php

index 7c2d86e6b669fdcd45e2e46eea2df87708c9b1a3..d1f70e87091a8ed4820576e14875d600ced0349d 100644 (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);
+       }
 }