View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
class WebformElementViewTest extends WebformElementBrowserTestBase {
public static $modules = [
'webform',
'webform_ui',
'views',
'views_ui',
];
protected static $testWebforms = [
'test_element_view',
];
public function testView() {
$this
->drupalGet('/webform/test_element_view');
$this
->assertRaw('No submissions available.');
$admin_webform_account = $this
->drupalCreateUser([
'administer webform',
]);
$this
->drupalLogin($admin_webform_account);
$this
->drupalGet('/admin/structure/webform/manage/test_element_view/element/view/edit');
$this
->assertRaw("Only users who can 'Administer views' or 'Edit webform source code' can update the view name, display id, and arguments.");
$this
->assertNoFieldByName('properties[name]');
$this
->assertNoFieldByName('properties[display_id]');
$admin_views_account = $this
->drupalCreateUser([
'administer webform',
'administer views',
]);
$this
->drupalLogin($admin_views_account);
$this
->drupalGet('/admin/structure/webform/manage/test_element_view/element/view/edit');
$this
->assertNoRaw("Only users who can 'Administer views' or 'Edit webform source code' can update the view name, display id, and arguments.");
$this
->assertFieldByName('properties[name]');
$this
->assertFieldByName('properties[display_id]');
$edit = [
'properties[name]' => 'xxx',
];
$this
->drupalPostForm('/admin/structure/webform/manage/test_element_view/element/view/edit', $edit, 'Save');
$this
->assertRaw('View <em class="placeholder">xxx</em> does not exist.');
$edit = [
'properties[display_id]' => 'xxx',
];
$this
->drupalPostForm('/admin/structure/webform/manage/test_element_view/element/view/edit', $edit, 'Save');
$this
->assertRaw('View display <em class="placeholder">xxx</em> does not exist.');
$edit = [
'properties[display_id]' => 'embed_administer',
];
$this
->drupalPostForm('/admin/structure/webform/manage/test_element_view/element/view/edit', $edit, 'Save');
$this
->assertRaw('View display <em class="placeholder">embed_administer</em> has exposed filters which will break the webform.');
$edit = [
'properties[display_id]' => 'embed_administer',
'properties[display_on]' => 'view',
];
$this
->drupalPostForm('/admin/structure/webform/manage/test_element_view/element/view/edit', $edit, 'Save');
$this
->assertNoRaw('View display <em class="placeholder">embed_administer</em> has exposed filters which will break the webform.');
}
}