aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFlorin Peter <github@florin-peter.de>2013-05-25 20:36:51 +0200
committerFlorin Peter <github@florin-peter.de>2013-05-25 20:36:51 +0200
commit4eddef1556ac7ee7fc0c7e82279672c52d9b6db9 (patch)
tree97d1ccb30b23480c0033ed73fd22609786efdf5d /tests
parent505a300776a958f4076f923b0966ab13eee3c4b5 (diff)
downloadnextcloud-server-4eddef1556ac7ee7fc0c7e82279672c52d9b6db9.tar.gz
nextcloud-server-4eddef1556ac7ee7fc0c7e82279672c52d9b6db9.zip
improved tests to check if database layer normalize folder names
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/cache/cache.php40
1 files changed, 29 insertions, 11 deletions
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index e693fb892cd..7b0453edb0d 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -243,10 +243,10 @@ class Cache extends \PHPUnit_Framework_TestCase {
* @brief this test show the bug resulting if we have no normalizer installed
*/
public function testWithoutNormalizer() {
- // create folder Schön with U+00F6
+ // folder name "Schön" with U+00F6 (normalized)
$folderWith00F6 = "\x53\x63\x68\xc3\xb6\x6e";
- // create folder Schön with U+0308
+ // folder name "Schön" with U+0308 (un-normalized)
$folderWith0308 = "\x53\x63\x68\x6f\xcc\x88\x6e";
/**
@@ -260,15 +260,24 @@ class Cache extends \PHPUnit_Framework_TestCase {
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
+ // put root folder
$this->assertFalse($cacheMock->get('folder'));
$this->assertGreaterThan(0, $cacheMock->put('folder', $data));
- $this->assertFalse($cacheMock->get('folder/' . $folderWith00F6));
- $this->assertGreaterThan(0, $cacheMock->put('folder/' .$folderWith00F6, $data));
-
+ // put un-normalized folder
$this->assertFalse($cacheMock->get('folder/' .$folderWith0308));
$this->assertGreaterThan(0, $cacheMock->put('folder/' .$folderWith0308, $data));
+ // get un-normalized folder by name
+ $unNormalizedFolderName = $cacheMock->get('folder/' .$folderWith0308);
+
+ // check if database layer normalized the folder name (this should not happen)
+ $this->assertEquals($folderWith0308, $unNormalizedFolderName['name']);
+
+ // put normalized folder
+ $this->assertFalse($cacheMock->get('folder/' . $folderWith00F6));
+ $this->assertGreaterThan(0, $cacheMock->put('folder/' .$folderWith00F6, $data));
+
// this is our bug, we have two different hashes with the same name (Schön)
$this->assertEquals(2, count($cacheMock->getFolderContents('folder')));
}
@@ -283,23 +292,32 @@ class Cache extends \PHPUnit_Framework_TestCase {
return;
}
- // folder name Schön with U+00F6
+ // folder name "Schön" with U+00F6 (normalized)
$folderWith00F6 = "\x53\x63\x68\xc3\xb6\x6e";
- // folder name Schön with U+0308
+ // folder name "Schön" with U+0308 (un-normalized)
$folderWith0308 = "\x53\x63\x68\x6f\xcc\x88\x6e";
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
+ // put root folder
$this->assertFalse($this->cache->get('folder'));
$this->assertGreaterThan(0, $this->cache->put('folder', $data));
- $this->assertFalse($this->cache->get('folder/' . $folderWith00F6));
- $this->assertGreaterThan(0, $this->cache->put('folder/' .$folderWith00F6, $data));
-
- $this->assertTrue(is_array($this->cache->get('folder/' .$folderWith0308)));
+ // put un-normalized folder
+ $this->assertFalse($this->cache->get('folder/' .$folderWith0308));
$this->assertGreaterThan(0, $this->cache->put('folder/' .$folderWith0308, $data));
+ // get un-normalized folder by name
+ $unNormalizedFolderName = $this->cache->get('folder/' .$folderWith0308);
+
+ // check if folder name was normalized
+ $this->assertEquals($folderWith00F6, $unNormalizedFolderName['name']);
+
+ // put normalized folder
+ $this->assertTrue(is_array($this->cache->get('folder/' . $folderWith00F6)));
+ $this->assertGreaterThan(0, $this->cache->put('folder/' .$folderWith00F6, $data));
+
// at this point we should have only one folder named "Schön"
$this->assertEquals(1, count($this->cache->getFolderContents('folder')));
}