Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F116098236
PhabricatorDiffScopeEngineTestCase.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
Wed, Jun 4, 22:07
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Jun 6, 22:07 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
26560091
Attached To
rPH Phabricator
PhabricatorDiffScopeEngineTestCase.php
View Options
<?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
;
}
}
Event Timeline
Log In to Comment