public function WebformSettingsFormTitleTest::testTitle in Webform 6.x
Same name and namespace in other branches
- 8.5 tests/src/Functional/Settings/WebformSettingsFormTitleTest.php \Drupal\Tests\webform\Functional\Settings\WebformSettingsFormTitleTest::testTitle()
Tests form title.
File
- tests/
src/ Functional/ Settings/ WebformSettingsFormTitleTest.php, line 27
Class
- WebformSettingsFormTitleTest
- Tests for webform form title.
Namespace
Drupal\Tests\webform\Functional\SettingsCode
public function testTitle() {
$node = $this
->drupalCreateNode([
'title' => 'test_node',
]);
$webform = Webform::create([
'langcode' => 'en',
'status' => WebformInterface::STATUS_OPEN,
'id' => 'test_webform',
'title' => 'test_webform',
'elements' => Yaml::encode([
'test' => [
'#markup' => 'test',
],
]),
'settings' => [
'form_prepopulate_source_entity' => TRUE,
],
]);
$webform
->save();
$options = [
'query' => [
'source_entity_type' => 'node',
'source_entity_id' => $node
->id(),
],
];
/**************************************************************************/
// Check webform title.
$this
->drupalGet('/webform/test_webform');
$this
->assertRaw('<title>test_webform | Drupal</title>');
// Check (default) both title.
$this
->drupalGet('/webform/test_webform', $options);
$this
->assertRaw('<title>test_node: test_webform | Drupal</title>');
// Check webform and source entity title.
$webform
->setSetting('form_title', WebformInterface::TITLE_WEBFORM_SOURCE_ENTITY)
->save();
$this
->drupalGet('/webform/test_webform', $options);
$this
->assertRaw('<title>test_webform: test_node | Drupal</title>');
// Check source entity title.
$webform
->setSetting('form_title', WebformInterface::TITLE_SOURCE_ENTITY)
->save();
$this
->drupalGet('/webform/test_webform', $options);
$this
->assertRaw('<title>test_node | Drupal</title>');
// Check webform title.
$webform
->setSetting('form_title', WebformInterface::TITLE_WEBFORM)
->save();
$this
->drupalGet('/webform/test_webform', $options);
$this
->assertRaw('<title>test_webform | Drupal</title>');
// Check duplicate titles.
$webform
->setSetting('form_title', WebformInterface::TITLE_SOURCE_ENTITY_WEBFORM)
->save();
$this
->drupalGet('/webform/test_webform', $options);
$this
->assertRaw('<title>test_node: test_webform | Drupal</title>');
$webform
->set('title', 'test_node')
->save();
$this
->drupalGet('/webform/test_webform', $options);
$this
->assertRaw('<title>test_node | Drupal</title>');
}