Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118<?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('Terminated Tree')); }
public function testThreeWayGraphJoin() { $nodes = array( 'A' => array('D', 'C', 'B'), 'B' => array('D'), 'C' => array('B', 'E', 'F'), 'D' => array(), 'E' => array(), 'F' => array(), );
$graph = $this->newGraph($nodes); $picture = array( '^', '||o', '|o|', 'x| ||', ' | x|', ' | x', );
$this->assertGraph($picture, $graph, pht('Three-Way 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); }
}