Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93942212
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
Mon, Dec 2, 17:17
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 4, 17:17 (2 d)
Engine
blob
Format
Raw Data
Handle
22726773
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