Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
assertNoErrorsLogged example
$this
->
drupalGet
(
''
)
;
$this
->
assertSession
(
)
->
statusCodeEquals
(
500
)
;
$this
->
assertSession
(
)
->
pageTextContains
(
'DatabaseAccessDeniedException'
)
;
$this
->
assertErrorLogged
(
$this
->expectedExceptionMessage
)
;
}
/** * Tests fallback to PHP error log when an exception is thrown while logging. */
public
function
testLoggerException
(
)
{
// Ensure the test error log is empty before these tests.
$this
->
assertNoErrorsLogged
(
)
;
$this
->expectedExceptionMessage = 'Deforestation';
\Drupal::
state
(
)
->
set
(
'error_service_test.break_logger', TRUE
)
;
$this
->
drupalGet
(
''
)
;
$this
->
assertSession
(
)
->
statusCodeEquals
(
500
)
;
$this
->
assertSession
(
)
->
pageTextContains
(
'The website encountered an unexpected error. Please try again later.'
)
;
$this
->
assertSession
(
)
->
pageTextContains
(
$this
->expectedExceptionMessage
)
;
// Find fatal error logged to the error.log
$errors
=
file
(
\Drupal::
root
(
)
. '/' .
$this
->siteDirectory . '/error.log'
)
;