public function DiffPluginVariousTest::testTextWithSummaryPlugin in Diff 8
Tests the TextWithSummary plugin.
@covers \Drupal\diff\Plugin\diff\Field\TextWithSummaryFieldBuilder
File
- tests/
src/ Functional/ DiffPluginVariousTest.php, line 375
Class
- DiffPluginVariousTest
- Tests the Diff module plugins.
Namespace
Drupal\Tests\diff\FunctionalCode
public function testTextWithSummaryPlugin() {
// Enable the comparison of the summary.
$config = \Drupal::configFactory()
->getEditable('diff.plugins');
$settings['compare_summary'] = TRUE;
$config
->set('fields.node.body.type', 'text_summary_field_diff_builder');
$config
->set('fields.node.body.settings', $settings);
$config
->save();
// Create an article, setting the body field.
$node = $this
->drupalCreateNode([
'type' => 'article',
'title' => 'Test article',
'body' => [
'value' => 'Foo value',
'summary' => 'Foo summary',
],
]);
// Edit the article and update these fields, creating a new revision.
$edit = [
'body[0][value]' => 'Bar value',
'body[0][summary]' => 'Bar summary',
'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('Body');
$this
->assertText('Foo value');
$this
->assertText('Foo summary');
$this
->assertText('Bar value');
$this
->assertText('Bar summary');
}