@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
at recaptime-dev/main 51 lines 1.2 kB view raw
1<?php 2 3final class PhabricatorDiffScopeEngineTestCase 4 extends PhabricatorTestCase { 5 6 private $engines = array(); 7 8 public function testScopeEngine() { 9 $this->assertScopeStart('zebra.c', 4, 2); 10 } 11 12 private function assertScopeStart($file, $line, $expect) { 13 $engine = $this->getScopeTestEngine($file); 14 15 $actual = $engine->getScopeStart($line); 16 $this->assertEqual( 17 $expect, 18 $actual, 19 pht( 20 'Expect scope for line %s to start on line %s (actual: %s) in "%s".', 21 $line, 22 $expect, 23 $actual, 24 $file)); 25 } 26 27 private function getScopeTestEngine($file) { 28 if (!isset($this->engines[$file])) { 29 $this->engines[$file] = $this->newScopeTestEngine($file); 30 } 31 32 return $this->engines[$file]; 33 } 34 35 private function newScopeTestEngine($file) { 36 $path = dirname(__FILE__).'/data/'.$file; 37 $data = Filesystem::readFile($path); 38 39 $lines = phutil_split_lines($data); 40 $map = array(); 41 foreach ($lines as $key => $line) { 42 $map[$key + 1] = $line; 43 } 44 45 $engine = id(new PhabricatorDiffScopeEngine()) 46 ->setLineTextMap($map); 47 48 return $engine; 49 } 50 51}