]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added storage tests for fopen with special chars 471/head
authorVincent Petry <pvince81@owncloud.com>
Mon, 4 Jul 2016 15:49:44 +0000 (17:49 +0200)
committerLukas Reschke <lukas@statuscode.ch>
Wed, 20 Jul 2016 13:13:24 +0000 (15:13 +0200)
This makes it possible to test special chars with unit tests.
There is already a test for directories but there was none for file
names.

apps/files_external/tests/env/start-swift-ceph.sh
tests/lib/Files/Storage/Storage.php

index b73fa899a6d427ca841694ffea2b0a91267095b1..3a299a6fa85ae220b58f1fe48b1278025f3ef724 100755 (executable)
@@ -80,7 +80,7 @@ if ! "$thisFolder"/env/wait-for-connection ${host} 80 600; then
     exit 1
 fi
 echo "Waiting another 15 seconds"
-sleep 15
+sleep 15 
 
 cat > $thisFolder/config.swift.php <<DELIM
 <?php
index ed2ea87f9d96cca0f7cd9c4679bef6096be249f0..04aafece2e35630827a41a8bc6d4fd31266bf577 100644 (file)
@@ -105,6 +105,17 @@ abstract class Storage extends \Test\TestCase {
                $this->assertEquals(array(), $content);
        }
 
+       public function fileNameProvider() {
+               return [
+                       ['file.txt'],
+                       [' file.txt'],
+                       ['folder .txt'],
+                       ['file with space.txt'],
+                       ['spéciäl fäile'],
+                       ['test single\'quote.txt'],
+               ];
+       }
+
        public function directoryProvider() {
                return [
                        ['folder'],
@@ -336,22 +347,25 @@ abstract class Storage extends \Test\TestCase {
                $this->assertFalse($this->instance->file_exists('/lorem.txt'));
        }
 
-       public function testFOpen() {
+       /**
+        * @dataProvider fileNameProvider
+        */
+       public function testFOpen($fileName) {
                $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
 
-               $fh = @$this->instance->fopen('foo', 'r');
+               $fh = @$this->instance->fopen($fileName, 'r');
                if ($fh) {
                        fclose($fh);
                }
                $this->assertFalse($fh);
-               $this->assertFalse($this->instance->file_exists('foo'));
+               $this->assertFalse($this->instance->file_exists($fileName));
 
-               $fh = $this->instance->fopen('foo', 'w');
+               $fh = $this->instance->fopen($fileName, 'w');
                fwrite($fh, file_get_contents($textFile));
                fclose($fh);
-               $this->assertTrue($this->instance->file_exists('foo'));
+               $this->assertTrue($this->instance->file_exists($fileName));
 
-               $fh = $this->instance->fopen('foo', 'r');
+               $fh = $this->instance->fopen($fileName, 'r');
                $content = stream_get_contents($fh);
                $this->assertEquals(file_get_contents($textFile), $content);
        }