View source
<?php
namespace Drupal\Tests\webform\Functional\Views;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformViewsBulkFormTest extends WebformBrowserTestBase {
public static $modules = [
'webform',
'webform_test_views',
];
public function testViewsBulkForm() {
$admin_submission_user = $this
->drupalCreateUser([
'administer webform submission',
]);
$this
->drupalLogin($admin_submission_user);
$this
->drupalGet('/admin/structure/webform/test/views_bulk_form');
$this
->assertRaw('No submissions available.');
$this
->drupalLogin($this->rootUser);
$webform = Webform::load('contact');
$sid = $this
->postSubmissionTest($webform);
$webform_submission = $this
->loadSubmission($sid);
$this
->drupalLogin($admin_submission_user);
$this
->assertFalse($webform_submission
->isSticky(), 'Webform submission is not sticky');
$edit = [
'webform_submission_bulk_form[0]' => TRUE,
'action' => 'webform_submission_make_sticky_action',
];
$this
->drupalPostForm('/admin/structure/webform/test/views_bulk_form', $edit, 'Apply to selected items');
$webform_submission = $this
->loadSubmission($webform_submission
->id());
$this
->assertTrue($webform_submission
->isSticky(), 'Webform submission has been made sticky');
$edit = [
'webform_submission_bulk_form[0]' => TRUE,
'action' => 'webform_submission_make_unsticky_action',
];
$this
->drupalPostForm('/admin/structure/webform/test/views_bulk_form', $edit, 'Apply to selected items');
$webform_submission = $this
->loadSubmission($webform_submission
->id());
$this
->assertFalse($webform_submission
->isSticky(), 'Webform submission is not sticky anymore');
$this
->assertFalse($webform_submission
->isLocked(), 'Webform submission is not locked');
$edit = [
'webform_submission_bulk_form[0]' => TRUE,
'action' => 'webform_submission_make_lock_action',
];
$this
->drupalPostForm('/admin/structure/webform/test/views_bulk_form', $edit, 'Apply to selected items');
$webform_submission = $this
->loadSubmission($webform_submission
->id());
$this
->assertTrue($webform_submission
->isLocked(), 'Webform submission has been locked');
$edit = [
'webform_submission_bulk_form[0]' => TRUE,
'action' => 'webform_submission_make_unlock_action',
];
$this
->drupalPostForm('/admin/structure/webform/test/views_bulk_form', $edit, 'Apply to selected items');
$webform_submission = $this
->loadSubmission($webform_submission
->id());
$this
->assertFalse($webform_submission
->isLocked(), 'Webform submission is not locked anymore');
$edit = [
'webform_submission_bulk_form[0]' => TRUE,
'action' => 'webform_submission_delete_action',
];
$this
->drupalPostForm('/admin/structure/webform/test/views_bulk_form', $edit, 'Apply to selected items');
$this
->drupalPostForm(NULL, [
'confirm_input' => TRUE,
], 'Delete');
$webform_submission = $this
->loadSubmission($webform_submission
->id());
$this
->assertNull($webform_submission, '1: Webform submission has been deleted');
$this
->drupalGet('/admin/structure/webform/test/views_bulk_form');
$this
->assertRaw('No submissions available.');
}
}