Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2890906
PhutilErrorHandlerTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
PhutilErrorHandlerTestCase.php
View Options
<?php
final
class
PhutilErrorHandlerTestCase
extends
PhutilTestCase
{
public
function
testProxyException
(
)
{
$a
=
new
Exception
(
'a'
)
;
$b
=
new
PhutilProxyException
(
'b'
,
$a
)
;
$c
=
new
PhutilProxyException
(
'c'
,
$b
)
;
$this
->
assertEqual
(
$a
,
$b
->
getPrevious
(
)
)
;
$this
->
assertEqual
(
$a
,
PhutilErrorHandler
::
getRootException
(
$b
)
)
;
$this
->
assertEqual
(
$a
,
PhutilErrorHandler
::
getPreviousException
(
$b
)
)
;
$this
->
assertEqual
(
$a
,
PhutilErrorHandler
::
getRootException
(
$c
)
)
;
$this
->
assertEqual
(
$b
,
PhutilErrorHandler
::
getPreviousException
(
$c
)
)
;
}
public
function
testSilenceHandler
(
)
{
// Errors should normally be logged.
$this
->
assertTrue
(
strlen
(
$this
->
emitError
(
)
)
>
0
)
;
// The "@" operator should silence errors.
$this
->
assertTrue
(
@
strlen
(
$this
->
emitError
(
)
)
===
0
)
;
}
private
function
emitError
(
)
{
$temporary_log
=
new
TempFile
(
)
;
$old_log
=
ini_get
(
'error_log'
)
;
ini_set
(
'error_log'
,
(string)
$temporary_log
)
;
trigger_error
(
pht
(
'(A synthetic error emitted during a unit test.)'
)
)
;
ini_set
(
'error_log'
,
$old_log
)
;
return
Filesystem
::
readFile
(
$temporary_log
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 14:19 (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1118462
Default Alt Text
PhutilErrorHandlerTestCase.php (1 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment