WebformElementPluginTest.php in Webform 8.5
File
tests/src/Functional/Element/WebformElementPluginTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Entity\WebformSubmission;
class WebformElementPluginTest extends WebformElementBrowserTestBase {
public static $modules = [
'webform',
'webform_test_element',
];
protected static $testWebforms = [
'test_element_plugin',
];
public function testElementPlugin() {
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/admin/reports/webform-plugins/elements');
$this
->assertNoRaw('<td><div class="webform-form-filter-text-source">managed_file</div></td>');
$this
->assertNoRaw('<td><div class="webform-form-filter-text-source">webform_term_select</div></td>');
\Drupal::service('module_installer')
->install([
'file',
'taxonomy',
]);
$this
->drupalGet('/admin/reports/webform-plugins/elements');
$this
->assertRaw('<td><div class="webform-form-filter-text-source">managed_file</div></td>');
$this
->assertRaw('<td><div class="webform-form-filter-text-source">webform_term_select</div></td>');
$webform_plugin_test = Webform::load('test_element_plugin');
$this
->drupalGet('/webform/test_element_plugin');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:preCreate');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:postCreate');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:prepare');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:setDefaultValue');
$sid = $this
->postSubmission($webform_plugin_test);
$webform_submission = WebformSubmission::load($sid);
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:preCreate');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:prepare');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:setDefaultValue');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement::validate');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:preSave');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:postSave insert');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:postLoad');
$this
->drupalPostForm('/admin/structure/webform/manage/test_element_plugin/submission/' . $sid . '/edit', [], 'Save');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:postLoad');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:prepare');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:setDefaultValue');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement::validate');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:preSave');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:postSave update');
$this
->drupalGet('/admin/structure/webform/manage/test_element_plugin/submission/' . $sid);
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:postLoad');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:formatHtml');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:formatText');
$this
->drupalGet('/admin/structure/webform/manage/test_element_plugin/submission/' . $sid . '/text');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:postLoad');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:formatText');
$this
->drupalPostForm('/admin/structure/webform/manage/test_element_plugin/submission/' . $sid . '/delete', [], 'Delete');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:preDelete');
$this
->assertRaw('Invoked: Drupal\\webform_test_element\\Plugin\\WebformElement\\WebformTestElement:postDelete');
$this
->assertRaw('<em class="placeholder">Test: Element: Test (plugin): Submission #' . $webform_submission
->serial() . '</em> has been deleted.');
}
}