]> source.dussan.org Git - nextcloud-server.git/commitdiff
some more test cases & fix on file name generation with index
authorThomas Mueller <thomas.mueller@tmit.eu>
Tue, 19 Mar 2013 15:57:54 +0000 (16:57 +0100)
committerThomas Mueller <thomas.mueller@tmit.eu>
Tue, 19 Mar 2013 15:57:54 +0000 (16:57 +0100)
lib/files/mapper.php
tests/lib/files/mapper.php

index 2b6890472e31b105ff61e3979dcd1c2bc82a7567..15f5f0628b5cd7ebee9072c1d234dfc2b9727c80 100644 (file)
@@ -191,8 +191,8 @@ class Mapper
 
                // apply index to file name
                if ($index !== null) {
-                       array_pop($sluggedElements);
-                       array_push($sluggedElements, $filename.'-'.$index);
+                       $last= array_pop($sluggedElements);
+                       array_push($sluggedElements, $last.'-'.$index);
                }
 
                // add back the extension
index 36221f8bcaa084a8e697c109c8afa6fab8c4e6aa..79005eefdcb58238aa977712452e7925185d4bea 100644 (file)
@@ -34,8 +34,19 @@ class Mapper extends \PHPUnit_Framework_TestCase {
        }
 
        public function testSlugifyPath() {
+               // with extension
                $this->assertEquals('D:/text.txt', $this->mapper->slugifyPath('D:/text.txt'));
                $this->assertEquals('D:/text-2.txt', $this->mapper->slugifyPath('D:/text.txt', 2));
                $this->assertEquals('D:/a/b/text.txt', $this->mapper->slugifyPath('D:/a/b/text.txt'));
+
+               // without extension
+               $this->assertEquals('D:/text', $this->mapper->slugifyPath('D:/text'));
+               $this->assertEquals('D:/text-2', $this->mapper->slugifyPath('D:/text', 2));
+               $this->assertEquals('D:/a/b/text', $this->mapper->slugifyPath('D:/a/b/text'));
+
+               // with double dot
+               $this->assertEquals('D:/text-text.txt', $this->mapper->slugifyPath('D:/text.text.txt'));
+               $this->assertEquals('D:/text-text-2.txt', $this->mapper->slugifyPath('D:/text.text.txt', 2));
+               $this->assertEquals('D:/a/b/text-text.txt', $this->mapper->slugifyPath('D:/a/b/text.text.txt'));
        }
 }