|
|
|
@ -8,6 +8,8 @@ |
|
|
|
|
|
|
|
|
|
namespace Test\Files\Cache; |
|
|
|
|
|
|
|
|
|
use PHPUnit_Framework_MockObject_MockObject; |
|
|
|
|
|
|
|
|
|
class LongId extends \OC\Files\Storage\Temporary { |
|
|
|
|
public function getId() { |
|
|
|
|
return 'long:' . str_repeat('foo', 50) . parent::getId(); |
|
|
|
@ -237,6 +239,71 @@ class Cache extends \PHPUnit_Framework_TestCase { |
|
|
|
|
$this->assertEquals(array(md5($storageId), 'foo'), \OC\Files\Cache\Cache::getById($id)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @brief this test show the bug resulting if we have no normalizer installed |
|
|
|
|
*/ |
|
|
|
|
public function testWithoutNormalizer() { |
|
|
|
|
// create folder Schön with U+00F6 |
|
|
|
|
$folderWith00F6 = "\x53\x63\x68\xc3\xb6\x6e"; |
|
|
|
|
|
|
|
|
|
// create folder Schön with U+0308 |
|
|
|
|
$folderWith0308 = "\x53\x63\x68\x6f\xcc\x88\x6e"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @var \OC\Files\Cache\Cache | PHPUnit_Framework_MockObject_MockObject $cacheMock |
|
|
|
|
*/ |
|
|
|
|
$cacheMock = $this->getMock('\OC\Files\Cache\Cache', array('normalize'), array($this->storage), '', true); |
|
|
|
|
|
|
|
|
|
$cacheMock->expects($this->any()) |
|
|
|
|
->method('normalize') |
|
|
|
|
->will($this->returnArgument(0)); |
|
|
|
|
|
|
|
|
|
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); |
|
|
|
|
|
|
|
|
|
$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)); |
|
|
|
|
|
|
|
|
|
$this->assertFalse($cacheMock->get('folder/' .$folderWith0308)); |
|
|
|
|
$this->assertGreaterThan(0, $cacheMock->put('folder/' .$folderWith0308, $data)); |
|
|
|
|
|
|
|
|
|
// this is our bug, we have two different hashes with the same name (Schön) |
|
|
|
|
$this->assertEquals(2, count($cacheMock->getFolderContents('folder'))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @brief this test shows that there is no bug if we use the normalizer |
|
|
|
|
*/ |
|
|
|
|
public function testWithNormalizer() { |
|
|
|
|
|
|
|
|
|
if(!class_exists('Normalizer')) { |
|
|
|
|
$this->markTestSkipped('The Normalizer extension is not available.'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// folder name Schön with U+00F6 |
|
|
|
|
$folderWith00F6 = "\x53\x63\x68\xc3\xb6\x6e"; |
|
|
|
|
|
|
|
|
|
// folder name Schön with U+0308 |
|
|
|
|
$folderWith0308 = "\x53\x63\x68\x6f\xcc\x88\x6e"; |
|
|
|
|
|
|
|
|
|
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); |
|
|
|
|
|
|
|
|
|
$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))); |
|
|
|
|
$this->assertGreaterThan(0, $this->cache->put('folder/' .$folderWith0308, $data)); |
|
|
|
|
|
|
|
|
|
// at this point we should have only one folder named "Schön" |
|
|
|
|
$this->assertEquals(1, count($this->cache->getFolderContents('folder'))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function tearDown() { |
|
|
|
|
$this->cache->clear(); |
|
|
|
|
} |
|
|
|
|