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.
1.2 kB · 51 lines
PHP
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152<?php
final class PhabricatorDiffScopeEngineTestCase extends PhabricatorTestCase {
private $engines = array();
public function testScopeEngine() { $this->assertScopeStart('zebra.c', 4, 2); }
private function assertScopeStart($file, $line, $expect) { $engine = $this->getScopeTestEngine($file);
$actual = $engine->getScopeStart($line); $this->assertEqual( $expect, $actual, pht( 'Expect scope for line %s to start on line %s (actual: %s) in "%s".', $line, $expect, $actual, $file)); }
private function getScopeTestEngine($file) { if (!isset($this->engines[$file])) { $this->engines[$file] = $this->newScopeTestEngine($file); }
return $this->engines[$file]; }
private function newScopeTestEngine($file) { $path = dirname(__FILE__).'/data/'.$file; $data = Filesystem::readFile($path);
$lines = phutil_split_lines($data); $map = array(); foreach ($lines as $key => $line) { $map[$key + 1] = $line; }
$engine = id(new PhabricatorDiffScopeEngine()) ->setLineTextMap($map);
return $engine; }
}