Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
4eddef15
Commit
4eddef15
authored
11 years ago
by
Florin Peter
Browse files
Options
Downloads
Patches
Plain Diff
improved tests to check if database layer normalize folder names
parent
505a3007
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/lib/files/cache/cache.php
+29
-11
29 additions, 11 deletions
tests/lib/files/cache/cache.php
with
29 additions
and
11 deletions
tests/lib/files/cache/cache.php
+
29
−
11
View file @
4eddef15
...
...
@@ -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'
)));
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment