Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92980272
PhutilBugtraqParserTestCase.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, Nov 25, 08:07
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Nov 27, 08:07 (2 d)
Engine
blob
Format
Raw Data
Handle
22551893
Attached To
rPHU libphutil
PhutilBugtraqParserTestCase.php
View Options
<?php
final
class
PhutilBugtraqParserTestCase
extends
PhutilTestCase
{
public
function
testBugtraq
()
{
$actual
=
id
(
new
PhutilBugtraqParser
())
->
setBugtraqPattern
(
'http://bugs.com/%BUGID%'
)
->
setBugtraqCaptureExpression
(
'/[Ii]ssues?:?(
\s
*,?
\s
*
\d
+)+/'
)
->
setBugtraqSelectExpression
(
'/(
\d
+)/'
)
->
processCorpus
(
'Issues: 123, 345'
);
$this
->
assertEqual
(
'Issues: http://bugs.com/123, http://bugs.com/345'
,
$actual
);
$actual
=
id
(
new
PhutilBugtraqParser
())
->
setBugtraqPattern
(
'<%BUGID%>'
)
->
setBugtraqCaptureExpression
(
'/([A-Z]{2,}-
\d
+)/'
)
->
processCorpus
(
'AB-1 BC-2 CD-3'
);
$this
->
assertEqual
(
'<AB-1> <BC-2> <CD-3>'
,
$actual
);
$actual
=
id
(
new
PhutilBugtraqParser
())
->
setBugtraqPattern
(
'<%BUGID%>'
)
->
setBugtraqCaptureExpression
(
'/
\d
+/'
)
->
processCorpus
(
'This text has no bugs in it.'
);
$this
->
assertEqual
(
'This text has no bugs in it.'
,
$actual
);
$actual
=
id
(
new
PhutilBugtraqParser
())
->
setBugtraqPattern
(
'<%BUGID%>'
)
->
setBugtraqCaptureExpression
(
'/.*/'
)
->
setBugtraqSelectExpression
(
'/(
\d
+)/'
)
->
processCorpus
(
'This text captures but does not select.'
);
$this
->
assertEqual
(
'This text captures but does not select.'
,
$actual
);
$caught
=
null
;
try
{
id
(
new
PhutilBugtraqParser
())
->
setBugtraqCaptureExpression
(
'!'
);
}
catch
(
Exception
$ex
)
{
$caught
=
$ex
;
}
$this
->
assertTrue
(
$caught
instanceof
PhutilTypeCheckException
);
$caught
=
null
;
try
{
id
(
new
PhutilBugtraqParser
())
->
setBugtraqSelectExpression
(
'!'
);
}
catch
(
Exception
$ex
)
{
$caught
=
$ex
;
}
$this
->
assertTrue
(
$caught
instanceof
PhutilTypeCheckException
);
}
}
Event Timeline
Log In to Comment