Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96172880
ProjectRemarkupRuleTestCase.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
Mon, Dec 23, 10:51
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 10:51 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23138315
Attached To
rPH Phabricator
ProjectRemarkupRuleTestCase.php
View Options
<?php
final
class
ProjectRemarkupRuleTestCase
extends
PhabricatorTestCase
{
public
function
testProjectObjectRemarkup
()
{
$cases
=
array
(
'I like #ducks.'
=>
array
(
'embed'
=>
array
(),
'ref'
=>
array
(
array
(
'offset'
=>
8
,
'id'
=>
'ducks'
,
),
),
),
'We should make a post on #blog.example.com tomorrow.'
=>
array
(
'embed'
=>
array
(),
'ref'
=>
array
(
array
(
'offset'
=>
26
,
'id'
=>
'blog.example.com'
,
),
),
),
'We should make a post on #blog.example.com.'
=>
array
(
'embed'
=>
array
(),
'ref'
=>
array
(
array
(
'offset'
=>
26
,
'id'
=>
'blog.example.com'
,
),
),
),
'#123'
=>
array
(
'embed'
=>
array
(),
'ref'
=>
array
(),
),
'#security#123'
=>
array
(
'embed'
=>
array
(),
'ref'
=>
array
(
array
(
'offset'
=>
1
,
'id'
=>
'security'
,
'tail'
=>
'123'
,
),
),
),
// Don't match a terminal parenthesis. This fixes these constructs in
// natural language.
'There is some documentation (see #guides).'
=>
array
(
'embed'
=>
array
(),
'ref'
=>
array
(
array
(
'offset'
=>
34
,
'id'
=>
'guides'
,
),
),
),
// Don't match internal parentheses either. This makes the terminal
// parenthesis behavior less arbitrary (otherwise, we match open
// parentheses but not closing parentheses, which is surprising).
'#a(b)c'
=>
array
(
'embed'
=>
array
(),
'ref'
=>
array
(
array
(
'offset'
=>
1
,
'id'
=>
'a'
,
),
),
),
'#s3'
=>
array
(
'embed'
=>
array
(),
'ref'
=>
array
(
array
(
'offset'
=>
1
,
'id'
=>
's3'
,
),
),
),
);
foreach
(
$cases
as
$input
=>
$expect
)
{
$rule
=
new
ProjectRemarkupRule
();
$matches
=
$rule
->
extractReferences
(
$input
);
$this
->
assertEqual
(
$expect
,
$matches
,
$input
);
}
}
}
Event Timeline
Log In to Comment