public function WebformHandlerExcludedTest::testExcludeHandlers in Webform 8.5
Same name and namespace in other branches
- 6.x tests/src/Functional/Handler/WebformHandlerExcludedTest.php \Drupal\Tests\webform\Functional\Handler\WebformHandlerExcludedTest::testExcludeHandlers()
Test excluded handlers.
File
- tests/
src/ Functional/ Handler/ WebformHandlerExcludedTest.php, line 32
Class
- WebformHandlerExcludedTest
- Tests for the webform handler excluded.
Namespace
Drupal\Tests\webform\Functional\HandlerCode
public function testExcludeHandlers() {
$this
->drupalLogin($this->rootUser);
/** @var \Drupal\webform\Plugin\WebformHandlerManagerInterface $handler_manager */
$handler_manager = $this->container
->get('plugin.manager.webform.handler');
// Check add mail and handler plugin.
$this
->drupalGet('/admin/structure/webform/manage/contact/handlers');
$this
->assertLink('Add email');
$this
->assertLink('Add handler');
// Check add mail accessible.
$this
->drupalGet('/admin/structure/webform/manage/contact/handlers/add/email');
$this
->assertResponse(200);
// Exclude the email handler.
\Drupal::configFactory()
->getEditable('webform.settings')
->set('handler.excluded_handlers', [
'email' => 'email',
])
->save();
// Check add mail hidden.
$this
->drupalGet('/admin/structure/webform/manage/contact/handlers');
$this
->assertNoLink('Add email');
$this
->assertLink('Add handler');
// Check add mail access denied.
$this
->drupalGet('/admin/structure/webform/manage/contact/handlers/add/email');
$this
->assertResponse(403);
// Exclude the email handler.
\Drupal::configFactory()
->getEditable('webform.settings')
->set('handler.excluded_handlers', [
'action' => 'action',
'broken' => 'broken',
'debug' => 'debug',
'email' => 'email',
'remote_post' => 'remote_post',
'settings' => 'settings',
])
->save();
// Check add mail and handler hidden.
$this
->drupalGet('/admin/structure/webform/manage/contact/handlers');
$this
->assertNoLink('Add email');
$this
->assertNoLink('Add handler');
// Check handler definitions.
$definitions = $handler_manager
->getDefinitions();
$definitions = $handler_manager
->removeExcludeDefinitions($definitions);
$this
->assertEqual(array_keys($definitions), []);
}