Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98202007
PhabricatorSlugTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jan 11, 00:26
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Jan 13, 00:26 (2 d)
Engine
blob
Format
Raw Data
Handle
23532870
Attached To
rPH Phabricator
PhabricatorSlugTestCase.php
View Options
<?php
final
class
PhabricatorSlugTestCase
extends
PhabricatorTestCase
{
public
function
testSlugNormalization
()
{
$slugs
=
array
(
''
=>
'/'
,
'/'
=>
'/'
,
'//'
=>
'/'
,
'&&&'
=>
'/'
,
'/derp/'
=>
'derp/'
,
'derp'
=>
'derp/'
,
'derp//derp'
=>
'derp/derp/'
,
'DERP//DERP'
=>
'derp/derp/'
,
'a B c'
=>
'a_b_c/'
,
'-1~2.3abcd'
=>
'-1~2.3abcd/'
,
"T
\x
00O
\x
00D
\x
00O"
=>
"t_o_d_o/"
,
'x#%&+=
\\
?<> y'
=>
'x_y/'
,
"
\x
E2
\x
98
\x
83"
=>
"
\x
E2
\x
98
\x
83/"
,
'..'
=>
'dotdot/'
,
'../'
=>
'dotdot/'
,
'/../'
=>
'dotdot/'
,
'a/b'
=>
'a/b/'
,
'a//b'
=>
'a/b/'
,
'a/../b/'
=>
'a/dotdot/b/'
,
'/../a'
=>
'dotdot/a/'
,
'../a'
=>
'dotdot/a/'
,
'a/..'
=>
'a/dotdot/'
,
'a/../'
=>
'a/dotdot/'
,
);
foreach
(
$slugs
as
$slug
=>
$normal
)
{
$this
->
assertEqual
(
$normal
,
PhabricatorSlug
::
normalize
(
$slug
),
"Normalization of '{$slug}'"
);
}
}
public
function
testSlugAncestry
()
{
$slugs
=
array
(
'/'
=>
array
(),
'pokemon/'
=>
array
(
'/'
),
'pokemon/squirtle/'
=>
array
(
'/'
,
'pokemon/'
),
);
foreach
(
$slugs
as
$slug
=>
$ancestry
)
{
$this
->
assertEqual
(
$ancestry
,
PhabricatorSlug
::
getAncestry
(
$slug
),
"Ancestry of '{$slug}'"
);
}
}
public
function
testSlugDepth
()
{
$slugs
=
array
(
'/'
=>
0
,
'a/'
=>
1
,
'a/b/'
=>
2
,
'a////b/'
=>
2
,
);
foreach
(
$slugs
as
$slug
=>
$depth
)
{
$this
->
assertEqual
(
$depth
,
PhabricatorSlug
::
getDepth
(
$slug
),
"Depth of '{$slug}'"
);
}
}
}
Event Timeline
Log In to Comment