summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-07-21 14:25:38 +0200
committerMorris Jobke <hey@morrisjobke.de>2017-07-22 11:05:05 +0200
commit89aaded07f899d46ebed285bae0a6a2c4fbf7ae0 (patch)
treebe84ccf9455e50921fd39694a71060d9b0d3e912 /tests/lib
parent9a151056d034f4124ea837f77b5a13f35834fd22 (diff)
downloadnextcloud-server-89aaded07f899d46ebed285bae0a6a2c4fbf7ae0.tar.gz
nextcloud-server-89aaded07f899d46ebed285bae0a6a2c4fbf7ae0.zip
add tests for renaming paths with multibyte utf8 characters
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Files/Cache/CacheTest.php74
1 files changed, 38 insertions, 36 deletions
diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php
index 0038cef1f63..5e6301d689a 100644
--- a/tests/lib/Files/Cache/CacheTest.php
+++ b/tests/lib/Files/Cache/CacheTest.php
@@ -488,48 +488,50 @@ class CacheTest extends \Test\TestCase {
, 10, 0, [], $user)));
}
- function testMove() {
- $file1 = 'folder';
- $file2 = 'folder/bar';
- $file3 = 'folder/foo';
- $file4 = 'folder/foo/1';
- $file5 = 'folder/foo/2';
+ function movePathProvider() {
+ return [
+ ['folder/foo', 'folder/foobar', ['1', '2']],
+ ['folder/foo', 'foo', ['1', '2']],
+ ['files/Индустрия_Инженерные системы ЦОД', 'files/Индустрия_Инженерные системы ЦОД1', ['1', '2']],
+ ];
+ }
+
+ /**
+ * @dataProvider movePathProvider
+ */
+ function testMove($sourceFolder, $targetFolder, $children) {
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar');
$folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
- $this->cache->put($file1, $folderData);
- $this->cache->put($file2, $folderData);
- $this->cache->put($file3, $folderData);
- $this->cache->put($file4, $data);
- $this->cache->put($file5, $data);
+ // create folders
+ foreach ([$sourceFolder, $targetFolder] as $current) {
+ while (strpos($current, '/') > 0) {
+ $current = dirname($current);
+ $this->cache->put($current, $folderData);
+ $this->cache2->put($current, $folderData);
+ }
+ }
- /* simulate a second user with a different storage id but the same folder structure */
- $this->cache2->put($file1, $folderData);
- $this->cache2->put($file2, $folderData);
- $this->cache2->put($file3, $folderData);
- $this->cache2->put($file4, $data);
- $this->cache2->put($file5, $data);
+ $this->cache->put($sourceFolder, $folderData);
+ $this->cache2->put($sourceFolder, $folderData);
+ foreach ($children as $child) {
+ $this->cache->put($sourceFolder . '/' . $child, $data);
+ $this->cache2->put($sourceFolder . '/' . $child, $data);
+ }
- $this->cache->move('folder/foo', 'folder/foobar');
+ $this->cache->move($sourceFolder, $targetFolder);
- $this->assertFalse($this->cache->inCache('folder/foo'));
- $this->assertFalse($this->cache->inCache('folder/foo/1'));
- $this->assertFalse($this->cache->inCache('folder/foo/2'));
-
- $this->assertTrue($this->cache->inCache('folder/bar'));
- $this->assertTrue($this->cache->inCache('folder/foobar'));
- $this->assertTrue($this->cache->inCache('folder/foobar/1'));
- $this->assertTrue($this->cache->inCache('folder/foobar/2'));
-
- /* the folder structure of the second user must not change! */
- $this->assertTrue($this->cache2->inCache('folder/bar'));
- $this->assertTrue($this->cache2->inCache('folder/foo'));
- $this->assertTrue($this->cache2->inCache('folder/foo/1'));
- $this->assertTrue($this->cache2->inCache('folder/foo/2'));
-
- $this->assertFalse($this->cache2->inCache('folder/foobar'));
- $this->assertFalse($this->cache2->inCache('folder/foobar/1'));
- $this->assertFalse($this->cache2->inCache('folder/foobar/2'));
+
+ $this->assertFalse($this->cache->inCache($sourceFolder));
+ $this->assertTrue($this->cache2->inCache($sourceFolder));
+ $this->assertTrue($this->cache->inCache($targetFolder));
+ $this->assertFalse($this->cache2->inCache($targetFolder));
+ foreach ($children as $child) {
+ $this->assertFalse($this->cache->inCache($sourceFolder . '/' . $child));
+ $this->assertTrue($this->cache2->inCache($sourceFolder . '/' . $child));
+ $this->assertTrue($this->cache->inCache($targetFolder . '/' . $child));
+ $this->assertFalse($this->cache2->inCache($targetFolder . '/' . $child));
+ }
}
function testGetIncomplete() {