You are here

public function WebformNodeTranslationTest::testNodeTranslation in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_node/tests/src/Functional/WebformNodeTranslationTest.php \Drupal\Tests\webform_node\Functional\WebformNodeTranslationTest::testNodeTranslation()

Tests webform node translation.

File

modules/webform_node/tests/src/Functional/WebformNodeTranslationTest.php, line 22

Class

WebformNodeTranslationTest
Tests for webform node translation.

Namespace

Drupal\Tests\webform_node\Functional

Code

public function testNodeTranslation() {
  $node = $this
    ->createWebformNode('webform_node_test_translation', [
    'title' => 'English node',
  ]);

  // Check computed token uses the English title.
  $this
    ->drupalGet('/node/' . $node
    ->id());
  $this
    ->assertFieldByName('computed_token', 'English node');

  // Create spanish node.
  $node
    ->addTranslation('es', [
    'title' => 'Spanish node',
  ])
    ->save();

  // Check computed token uses the Spanish title.
  $this
    ->drupalGet('/es/node/' . $node
    ->id());
  $this
    ->assertNoFieldByName('computed_token', 'English node');
  $this
    ->assertFieldByName('computed_token', 'Spanish node');
}