WebformSettingsArchivedTest.php in Webform 8.5
File
tests/src/Functional/Settings/WebformSettingsArchivedTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Settings;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformSettingsArchivedTest extends WebformBrowserTestBase {
public static $modules = [
'webform_node',
'webform_templates',
'webform',
];
protected static $testWebforms = [
'test_form_archived',
];
public function testArchived() {
global $base_path;
$this
->drupalLogin($this->rootUser);
$webform = Webform::load('test_form_archived');
$this
->drupalGet('/admin/structure/webform');
$this
->assertRaw('<td><a href="' . $base_path . 'form/contact">Contact</a></td>');
$this
->assertNoRaw('<td><a href="' . $base_path . 'form/test-form-archived">Test: Webform: Archive</a></td>');
$this
->drupalGet('/admin/structure/webform', [
'query' => [
'state' => 'archived',
],
]);
$this
->assertNoRaw('<td><a href="' . $base_path . 'form/contact">Contact</a></td>');
$this
->assertRaw('<td><a href="' . $base_path . 'form/test-form-archived">Test: Webform: Archive</a></td>');
$this
->drupalGet('/form/test-form-archived');
$this
->assertRaw('This webform is <a href="' . $base_path . 'admin/structure/webform/manage/test_form_archived/settings">archived</a>');
$this
->drupalGet('/node/add/webform');
$this
->assertRaw('<option value="contact">Contact</option>');
$this
->assertNoRaw('Test: Webform: Archive');
$this
->drupalGet('/node/add/webform', [
'query' => [
'webform_id' => 'test_form_archived',
],
]);
$this
->assertRaw('<option value="contact">Contact</option>');
$this
->assertRaw('<optgroup label="Archived"><option value="test_form_archived" selected="selected">Test: Webform: Archive</option></optgroup>');
$webform
->set('template', TRUE);
$webform
->save();
$this
->drupalGet('/admin/structure/webform');
$this
->assertRaw('Contact');
$this
->assertNoRaw('Test: Webform: Archive');
$this
->drupalGet('/admin/structure/webform', [
'query' => [
'state' => 'archived',
],
]);
$this
->assertNoRaw('Contact');
$this
->assertRaw('<td><a href="' . $base_path . 'form/test-form-archived">Test: Webform: Archive</a> <b>(Template)</b></td>');
$this
->drupalGet('/form/test-form-archived');
$this
->assertRaw('This webform is <a href="' . $base_path . 'admin/structure/webform/manage/test_form_archived/settings">archived</a>');
}
}