public function WebformBlockTest::testBlock in Webform 8.5
Same name and namespace in other branches
- 6.x tests/src/Functional/Block/WebformBlockTest.php \Drupal\Tests\webform\Functional\Block\WebformBlockTest::testBlock()
Tests webform block.
File
- tests/
src/ Functional/ Block/ WebformBlockTest.php, line 31
Class
- WebformBlockTest
- Tests for webform block.
Namespace
Drupal\Tests\webform\Functional\BlockCode
public function testBlock() {
// Place block.
$block = $this
->drupalPlaceBlock('webform_block', [
'webform_id' => 'contact',
]);
// Check contact webform.
$this
->drupalGet('/<front>');
$this
->assertRaw('webform-submission-contact-add-form');
// Check contact webform with default data.
$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');
// Check confirmation inline webform.
$block
->getPlugin()
->setConfigurationValue('webform_id', 'test_confirmation_inline');
$block
->save();
$this
->drupalPostForm('/<front>', [], 'Submit');
$this
->assertRaw('This is a custom inline confirmation message.');
// Check confirmation message webform displayed on front page.
$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');
// Check confirmation message webform display on webform URL.
$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');
}