public function WebformNodeVariantTest::testNodeVariant in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_node/tests/src/Functional/WebformNodeVariantTest.php \Drupal\Tests\webform_node\Functional\WebformNodeVariantTest::testNodeVariant()
Tests webform node variant.
File
- modules/webform_node/ tests/ src/ Functional/ WebformNodeVariantTest.php, line 31 
Class
- WebformNodeVariantTest
- Tests for webform node variants.
Namespace
Drupal\Tests\webform_node\FunctionalCode
public function testNodeVariant() {
  // Create a webform node with a variant.
  $node = $this
    ->createWebformNode('test_variant_multiple');
  $node->webform->default_data = "letter: a\nnumber: '1'";
  $node
    ->save();
  /**************************************************************************/
  $this
    ->drupalLogin($this->rootUser);
  // Check node variants render.
  $this
    ->drupalGet('/node/' . $node
    ->id());
  $this
    ->assertRaw('[A]');
  $this
    ->assertRaw('[1]');
  // Check node variants processed.
  $sid = $this
    ->postNodeSubmission($node);
  $webform_submission = WebformSubmission::load($sid);
  $this
    ->assertEquals([
    'letter' => 'a',
    'number' => '1',
  ], $webform_submission
    ->getData());
  // Check node variants test processed.
  $sid = $this
    ->postNodeSubmissionTest($node);
  $webform_submission = WebformSubmission::load($sid);
  $this
    ->assertEquals([
    'letter' => 'a',
    'number' => '1',
  ], $webform_submission
    ->getData());
}