Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122178909
PHUIDiffGraphViewTestCase.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
Wed, Jul 16, 09:30
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Jul 18, 09:30 (2 d)
Engine
blob
Format
Raw Data
Handle
27445350
Attached To
rPH Phabricator
PHUIDiffGraphViewTestCase.php
View Options
<?php
final
class
PHUIDiffGraphViewTestCase
extends
PhabricatorTestCase
{
public
function
testTailTermination
()
{
$nodes
=
array
(
'A'
=>
array
(
'B'
),
'B'
=>
array
(
'C'
,
'D'
,
'E'
),
'E'
=>
array
(),
'D'
=>
array
(),
'C'
=>
array
(
'F'
,
'G'
),
'G'
=>
array
(),
'F'
=>
array
(),
);
$graph
=
$this
->
newGraph
(
$nodes
);
$picture
=
array
(
'^'
,
'o'
,
'||x'
,
'|x '
,
'o '
,
'|x '
,
'x '
,
);
$this
->
assertGraph
(
$picture
,
$graph
,
pht
(
'Terminating Tree'
));
}
public
function
testReverseTree
()
{
$nodes
=
array
(
'A'
=>
array
(
'B'
),
'C'
=>
array
(
'B'
),
'B'
=>
array
(
'D'
),
'E'
=>
array
(
'D'
),
'F'
=>
array
(
'D'
),
'D'
=>
array
(
'G'
),
'G'
=>
array
(),
);
$graph
=
$this
->
newGraph
(
$nodes
);
$picture
=
array
(
'^'
,
'|^'
,
'o '
,
'|^'
,
'||^'
,
'o '
,
'x'
,
);
$this
->
assertGraph
(
$picture
,
$graph
,
pht
(
'Reverse Tree'
));
}
public
function
testJoinTerminateTree
()
{
$nodes
=
array
(
'A'
=>
array
(
'D'
),
'B'
=>
array
(
'C'
),
'C'
=>
array
(
'D'
),
'D'
=>
array
(),
);
$graph
=
$this
->
newGraph
(
$nodes
);
$picture
=
array
(
'^'
,
'|^'
,
'|o'
,
'x '
,
);
$this
->
assertGraph
(
$picture
,
$graph
,
pht
(
'Reverse Tree'
));
}
private
function
newGraph
(
array
$nodes
)
{
return
id
(
new
PHUIDiffGraphView
())
->
setIsHead
(
true
)
->
setIsTail
(
true
)
->
renderRawGraph
(
$nodes
);
}
private
function
assertGraph
(
$picture
,
$graph
,
$label
)
{
list
(
$data
,
$count
)
=
$graph
;
$lines
=
ipull
(
$data
,
'line'
);
$picture
=
implode
(
"
\n
"
,
$picture
);
$lines
=
implode
(
"
\n
"
,
$lines
);
$this
->
assertEqual
(
$picture
,
$lines
,
$label
);
}
}
Event Timeline
Log In to Comment