View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
class WebformElementSubmissionViewsTest extends WebformElementBrowserTestBase {
public static $modules = [
'views',
'node',
'webform',
'webform_node',
];
protected static $testWebforms = [
'test_element_submission_views',
];
public function testSubmissionViews() {
$this
->drupalGet('/webform/test_element_submission_views');
$this
->assertRaw('<th class="webform_submission_views_global-table--name_title_view webform-multiple-table--name_title_view">');
$this
->assertRaw('<th class="webform_submission_views_global-table--global_routes webform-multiple-table--global_routes">');
$this
->assertRaw('<th class="webform_submission_views_global-table--webform_routes webform-multiple-table--webform_routes">');
$this
->assertRaw('<th class="webform_submission_views_global-table--node_routes webform-multiple-table--node_routes">');
$this
->assertRaw('<th class="webform_submission_views-table--name_title_view webform-multiple-table--name_title_view">');
$this
->assertNoRaw('<th class="webform_submission_views-table--global_routes webform-multiple-table--global_routes">');
$this
->assertRaw('<th class="webform_submission_views-table--webform_routes webform-multiple-table--webform_routes">');
$this
->assertRaw('<th class="webform_submission_views-table--node_routes webform-multiple-table--node_routes">');
$edit = [
'webform_submission_views_global[items][0][name]' => '',
];
$this
->drupalPostForm('/webform/test_element_submission_views', $edit, 'Submit');
$this
->assertRaw('Name is required');
$edit = [
'webform_submission_views_global[items][0][view]' => '',
];
$this
->drupalPostForm('/webform/test_element_submission_views', $edit, 'Submit');
$this
->assertRaw('View name/display id is required.');
$edit = [
'webform_submission_views_global[items][0][title]' => '',
];
$this
->drupalPostForm('/webform/test_element_submission_views', $edit, 'Submit');
$this
->assertRaw('Title is required.');
$this
->drupalPostForm('/webform/test_element_submission_views', [], 'Submit');
$this
->assertRaw("webform_submission_views_global:\n admin:\n view: 'webform_submissions:embed_administer'\n title: Admin\n global_routes:\n - entity.webform_submission.collection\n webform_routes:\n - entity.webform.results_submissions\n node_routes:\n - entity.node.webform.results_submissions\nwebform_submission_views:\n admin:\n view: 'webform_submissions:embed_administer'\n title: Admin\n webform_routes:\n - entity.webform.results_submissions\n node_routes:\n - entity.node.webform.results_submissions");
$edit = [
'webform_submission_views_global[items][0][name]' => '',
'webform_submission_views_global[items][0][view]' => '',
'webform_submission_views_global[items][0][title]' => '',
'webform_submission_views_global[items][0][global_routes][entity.webform_submission.collection]' => FALSE,
'webform_submission_views_global[items][0][webform_routes][entity.webform.results_submissions]' => FALSE,
'webform_submission_views_global[items][0][node_routes][entity.node.webform.results_submissions]' => FALSE,
];
$this
->drupalPostForm('/webform/test_element_submission_views', $edit, 'Submit');
$this
->assertNoRaw('Name is required');
$this
->assertNoRaw('View name/display id is required.');
$this
->assertNoRaw('Title is required.');
$this
->assertRaw("webform_submission_views_global: { }\nwebform_submission_views:\n admin:\n view: 'webform_submissions:embed_administer'\n title: Admin\n webform_routes:\n - entity.webform.results_submissions\n node_routes:\n - entity.node.webform.results_submissions");
$this->container
->get('module_installer')
->uninstall([
'webform_node',
]);
$this
->drupalGet('/webform/test_element_submission_views');
$this
->assertNoRaw('<th class="webform_submission_views_global-table--node_routes webform-multiple-table--node_routes">');
$this
->assertNoRaw('<th class="webform_submission_views-table--node_routes webform-multiple-table--node_routes">');
$this
->drupalPostForm('/webform/test_element_submission_views', [], 'Submit');
$this
->assertRaw("webform_submission_views_global:\n admin:\n view: 'webform_submissions:embed_administer'\n title: Admin\n global_routes:\n - entity.webform_submission.collection\n webform_routes:\n - entity.webform.results_submissions\nwebform_submission_views:\n admin:\n view: 'webform_submissions:embed_administer'\n title: Admin\n webform_routes:\n - entity.webform.results_submissions");
$this->container
->get('module_installer')
->uninstall([
'views',
]);
$this
->drupalGet('/webform/test_element_submission_views');
$this
->assertNoRaw('<th class="webform_submission_views_global-table--name_title_view webform-multiple-table--name_title_view">');
$this
->assertNoRaw('<th class="webform_submission_views-table--name_title_view webform-multiple-table--name_title_view">');
$this
->drupalPostForm('/webform/test_element_submission_views', [], 'Submit');
$this
->assertRaw("webform_submission_views_global: { }\nwebform_submission_views: { }");
}
}