View source
<?php
namespace Drupal\Tests\devel\Functional;
use Drupal\Component\Render\FormattableMarkup;
class DevelErrorHandlerTest extends DevelBrowserTestBase {
public function testErrorHandler() {
$messages_selector = '[data-drupal-messages]';
$expected_notice = 'This is an example notice';
$expected_warning = 'This is an example warning';
$config = $this
->config('system.logging');
$config
->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)
->save();
$this
->drupalLogin($this->adminUser);
$error_handlers = \Drupal::config('devel.settings')
->get('error_handlers');
$this
->assertEquals($error_handlers, [
DEVEL_ERROR_HANDLER_STANDARD => DEVEL_ERROR_HANDLER_STANDARD,
]);
$this
->drupalGet('admin/config/development/devel');
$this
->assertTrue($this
->assertSession()
->optionExists('edit-error-handlers', DEVEL_ERROR_HANDLER_STANDARD)
->hasAttribute('selected'));
$edit = [
'error_handlers[]' => DEVEL_ERROR_HANDLER_NONE,
];
$this
->drupalPostForm('admin/config/development/devel', $edit, 'Save configuration');
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$error_handlers = \Drupal::config('devel.settings')
->get('error_handlers');
$this
->assertEquals($error_handlers, [
DEVEL_ERROR_HANDLER_NONE => DEVEL_ERROR_HANDLER_NONE,
]);
$this
->assertTrue($this
->assertSession()
->optionExists('edit-error-handlers', DEVEL_ERROR_HANDLER_NONE)
->hasAttribute('selected'));
$this
->markTestSkipped('Unclear to me what this Error Handler feature does.');
$this
->clickLink('notice+warning');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextNotContains($expected_notice);
$this
->assertSession()
->pageTextNotContains($expected_warning);
$this
->assertSession()
->elementNotExists('css', $messages_selector);
$edit = [
'error_handlers[]' => DEVEL_ERROR_HANDLER_BACKTRACE_KINT,
];
$this
->drupalPostForm('admin/config/development/devel', $edit, 'Save configuration');
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$error_handlers = \Drupal::config('devel.settings')
->get('error_handlers');
$this
->assertEquals($error_handlers, [
DEVEL_ERROR_HANDLER_BACKTRACE_KINT => DEVEL_ERROR_HANDLER_BACKTRACE_KINT,
]);
$this
->assertTrue($this
->assertSession()
->optionExists('edit-error-handlers', DEVEL_ERROR_HANDLER_BACKTRACE_KINT)
->hasAttribute('selected'));
$this
->clickLink('notice+warning');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementNotExists('css', $messages_selector);
$edit = [
'error_handlers[]' => DEVEL_ERROR_HANDLER_BACKTRACE_DPM,
];
$this
->drupalPostForm('admin/config/development/devel', $edit, 'Save configuration');
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$error_handlers = \Drupal::config('devel.settings')
->get('error_handlers');
$this
->assertEquals($error_handlers, [
DEVEL_ERROR_HANDLER_BACKTRACE_DPM => DEVEL_ERROR_HANDLER_BACKTRACE_DPM,
]);
$this
->assertTrue($this
->assertSession()
->optionExists('edit-error-handlers', DEVEL_ERROR_HANDLER_BACKTRACE_DPM)
->hasAttribute('selected'));
$this
->clickLink('notice+warning');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementContains('css', $messages_selector, $expected_notice);
$this
->assertSession()
->elementContains('css', $messages_selector, $expected_warning);
$edit = [
'error_handlers[]' => [
DEVEL_ERROR_HANDLER_BACKTRACE_KINT => DEVEL_ERROR_HANDLER_BACKTRACE_KINT,
DEVEL_ERROR_HANDLER_BACKTRACE_DPM => DEVEL_ERROR_HANDLER_BACKTRACE_DPM,
],
];
$this
->drupalPostForm('admin/config/development/devel', $edit, 'Save configuration');
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$error_handlers = \Drupal::config('devel.settings')
->get('error_handlers');
$this
->assertEquals($error_handlers, [
DEVEL_ERROR_HANDLER_BACKTRACE_KINT => DEVEL_ERROR_HANDLER_BACKTRACE_KINT,
DEVEL_ERROR_HANDLER_BACKTRACE_DPM => DEVEL_ERROR_HANDLER_BACKTRACE_DPM,
]);
$this
->assertTrue($this
->assertSession()
->optionExists('edit-error-handlers', DEVEL_ERROR_HANDLER_BACKTRACE_KINT)
->hasAttribute('selected'));
$this
->assertTrue($this
->assertSession()
->optionExists('edit-error-handlers', DEVEL_ERROR_HANDLER_BACKTRACE_DPM)
->hasAttribute('selected'));
$this
->clickLink('notice+warning');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementContains('css', $messages_selector, $expected_notice);
$this
->assertSession()
->elementContains('css', $messages_selector, $expected_warning);
$config
->set('error_level', ERROR_REPORTING_DISPLAY_ALL)
->save();
$this
->clickLink('notice+warning');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementContains('css', $messages_selector, $expected_notice);
$this
->assertSession()
->elementContains('css', $messages_selector, $expected_warning);
$config
->set('error_level', ERROR_REPORTING_DISPLAY_SOME)
->save();
$this
->clickLink('notice+warning');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementContains('css', $messages_selector, $expected_notice);
$this
->assertSession()
->elementContains('css', $messages_selector, $expected_warning);
$config
->set('error_level', ERROR_REPORTING_HIDE)
->save();
$this
->clickLink('notice+warning');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextNotContains($expected_notice);
$this
->assertSession()
->pageTextNotContains($expected_warning);
$this
->assertSession()
->elementNotExists('css', $messages_selector);
}
}