WebformBlockTest.php in Webform 8.5
File
tests/src/Functional/Block/WebformBlockTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Block;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformBlockTest extends WebformBrowserTestBase {
public static $modules = [
'block',
'webform',
];
protected static $testWebforms = [
'test_confirmation_inline',
'test_confirmation_message',
];
public function testBlock() {
$block = $this
->drupalPlaceBlock('webform_block', [
'webform_id' => 'contact',
]);
$this
->drupalGet('/<front>');
$this
->assertRaw('webform-submission-contact-add-form');
$block
->getPlugin()
->setConfigurationValue('default_data', "name: 'John Smith'");
$block
->save();
$this
->drupalGet('/<front>');
$this
->assertRaw('webform-submission-contact-add-form');
$this
->assertFieldByName('name', 'John Smith');
$block
->getPlugin()
->setConfigurationValue('webform_id', 'test_confirmation_inline');
$block
->save();
$this
->drupalPostForm('/<front>', [], 'Submit');
$this
->assertRaw('This is a custom inline confirmation message.');
$block
->getPlugin()
->setConfigurationValue('webform_id', 'test_confirmation_message');
$block
->save();
$this
->drupalPostForm('/<front>', [], 'Submit');
$this
->assertRaw('This is a <b>custom</b> confirmation message.');
$this
->assertUrl('/user/login');
$block
->getPlugin()
->setConfigurationValue('redirect', TRUE);
$block
->save();
$this
->drupalPostForm('/<front>', [], 'Submit');
$this
->assertRaw('This is a <b>custom</b> confirmation message.');
$this
->assertUrl('webform/test_confirmation_message');
}
}