You are here

public function DiffPluginVariousTest::testTextPlugin in Diff 8

Tests the Text plugin.

@covers \Drupal\diff\Plugin\diff\Field\TextFieldBuilder

File

tests/src/Functional/DiffPluginVariousTest.php, line 338

Class

DiffPluginVariousTest
Tests the Diff module plugins.

Namespace

Drupal\Tests\diff\Functional

Code

public function testTextPlugin() {

  // Add a text and a text long field to the Article content type.
  $this
    ->addArticleTextField('field_text', 'Text Field', 'string', 'string_textfield');
  $this
    ->addArticleTextField('field_text_long', 'Text Long Field', 'string_long', 'string_textarea');

  // Create an article, setting values on both fields.
  $node = $this
    ->drupalCreateNode([
    'type' => 'article',
    'title' => 'Test article',
    'field_text' => 'Foo',
    'field_text_long' => 'Fighters',
  ]);

  // Edit the article and update these fields, creating a new revision.
  $edit = [
    'field_text[0][value]' => 'Bar',
    'field_text_long[0][value]' => 'Fly',
    'revision' => TRUE,
  ];
  $this
    ->drupalPostNodeForm('node/' . $node
    ->id() . '/edit', $edit, t('Save and keep published'));

  // Check differences between revisions.
  $this
    ->clickLink(t('Revisions'));
  $this
    ->drupalPostForm(NULL, [], t('Compare selected revisions'));
  $this
    ->assertText('Text Field');
  $this
    ->assertText('Text Long Field');
  $this
    ->assertText('Foo');
  $this
    ->assertText('Fighters');
  $this
    ->assertText('Bar');
  $this
    ->assertText('Fly');
}