WebformTemplatesTest.php in Webform 8.5
File
modules/webform_templates/tests/src/Functional/WebformTemplatesTest.php
View source
<?php
namespace Drupal\Tests\webform_templates\Functional;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
use Drupal\webform\Entity\Webform;
use Drupal\webform\WebformInterface;
class WebformTemplatesTest extends WebformBrowserTestBase {
public static $modules = [
'webform',
'webform_templates',
];
protected static $testWebforms = [
'test_form_template',
];
public function testTemplates() {
$user_account = $this
->drupalCreateUser([
'access webform overview',
'administer webform',
]);
$admin_account = $this
->drupalCreateUser([
'access webform overview',
'administer webform',
'administer webform templates',
]);
$this
->drupalLogin($user_account);
$template_webform = Webform::load('test_form_template');
$this
->assertTrue($template_webform
->isClosed());
$template_webform
->setStatus(WebformInterface::STATUS_OPEN)
->save();
$this
->assertTrue($template_webform
->isClosed());
$this
->drupalGet('/admin/structure/webform/templates');
$this
->assertRaw('Test: Webform: Template');
$this
->assertRaw('Test using a webform as a template.');
$this
->drupalGet('/webform/test_form_template');
$this
->assertResponse(200);
$this
->assertRaw('You are previewing the below template,');
$this
->drupalGet('/admin/structure/webform/manage/test_form_template/duplicate');
$this
->assertFieldByName('description[value]', '');
$this
->drupalGet('/admin/structure/webform/templates/manage');
$this
->assertResponse(403);
$this
->drupalLogin($admin_account);
$this
->drupalGet('/admin/structure/webform/templates/manage');
$this
->assertResponse(200);
$this
->drupalGet('/admin/structure/webform/manage/test_form_template/duplicate', [
'query' => [
'template' => 1,
],
]);
$this
->assertFieldByName('description[value]', 'Test using a webform as a template.');
}
}