You are here

public function YamlFormBlockTest::testBlock in YAML Form 8

Tests form block.

File

src/Tests/YamlFormBlockTest.php, line 15

Class

YamlFormBlockTest
Tests for form block.

Namespace

Drupal\yamlform\Tests

Code

public function testBlock() {

  // Place block.
  $block = $this
    ->drupalPlaceBlock('yamlform_block');

  // Check contact form.
  $block
    ->getPlugin()
    ->setConfigurationValue('yamlform_id', 'contact');
  $block
    ->save();
  $this
    ->drupalGet('<front>');
  $this
    ->assertRaw('yamlform-submission-contact-form');

  // Check contact form with default data.
  $block
    ->getPlugin()
    ->setConfigurationValue('default_data', "name: 'John Smith'");
  $block
    ->save();
  $this
    ->drupalGet('<front>');
  $this
    ->assertRaw('yamlform-submission-contact-form');
  $this
    ->assertFieldByName('name', 'John Smith');

  // Check confirmation inline form.
  $block
    ->getPlugin()
    ->setConfigurationValue('yamlform_id', 'test_confirmation_inline');
  $block
    ->save();
  $this
    ->drupalPostForm('<front>', [], t('Submit'));
  $this
    ->assertRaw('This is a custom inline confirmation message.');

  // Check confirmation message form.
  $block
    ->getPlugin()
    ->setConfigurationValue('yamlform_id', 'test_confirmation_message');
  $block
    ->save();
  $this
    ->drupalPostForm('<front>', [], t('Submit'));
  $this
    ->assertRaw('This is a <b>custom</b> confirmation message.');
}