Path: blob/master/src/infrastructure/diff/__tests__/PhabricatorDiffScopeEngineTestCase.php
12242 views
<?php12final class PhabricatorDiffScopeEngineTestCase3extends PhabricatorTestCase {45private $engines = array();67public function testScopeEngine() {8$this->assertScopeStart('zebra.c', 4, 2);9}1011private function assertScopeStart($file, $line, $expect) {12$engine = $this->getScopeTestEngine($file);1314$actual = $engine->getScopeStart($line);15$this->assertEqual(16$expect,17$actual,18pht(19'Expect scope for line %s to start on line %s (actual: %s) in "%s".',20$line,21$expect,22$actual,23$file));24}2526private function getScopeTestEngine($file) {27if (!isset($this->engines[$file])) {28$this->engines[$file] = $this->newScopeTestEngine($file);29}3031return $this->engines[$file];32}3334private function newScopeTestEngine($file) {35$path = dirname(__FILE__).'/data/'.$file;36$data = Filesystem::readFile($path);3738$lines = phutil_split_lines($data);39$map = array();40foreach ($lines as $key => $line) {41$map[$key + 1] = $line;42}4344$engine = id(new PhabricatorDiffScopeEngine())45->setLineTextMap($map);4647return $engine;48}4950}515253