Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F95676370
PhutilErrorHandlerTestCase.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, Dec 18, 06:59
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Dec 20, 06:59 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23039376
Attached To
rPHU libphutil
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
);
}
}
Event Timeline
Log In to Comment